Using prepared Dockerfiles with a certain template format is common. It is certainly a very useful approach. Passing arguments and using environment variables during builds will create different images for different CI/CD stages, for example, using the same Dockerfile.
Templating is key when building using CI/CD orchestration, but there are a few rules:
- Don't use debugging tools in production images, so take care of these images and use slimmer ones (with fewer components) by default in templates.
- Don't use credentials as arguments when building. There are other mechanisms for managing users and passwords and the Docker history command will reveal this information.
- Proxy settings are prepared for use as arguments. Therefore, the HTTP_PROXY, HTTPS_PROXY, FTP_PROXY, and NO_PROXY environment variables can be used during build time. These variables will be excluded from the Docker history output and will not be cached, so we will need to use an ARG definition...