docker-selenium
docker-selenium copied to clipboard
[🚀 Feature]: Using --build-arg to substitute the IMAGE_TAG name instead of generating copies of Dockerfiles during the build process.
Feature and motivation
Based on a conversation with @AutomationD and diemol, we now know container Dockerfiles have the ability to substitute values in the FROM block with arguments passed in as --build-arg
. Currently, we are generating Dockerfiles from Dockerfile.txt files and replacing templated values with real ones using a shell script.
Instead, we can simplify this process using docker build --build-arg $IMAGE_TAG
, which then allows us to:
- eliminate the generate.sh scripts
- Remove Dockerfiles from all except the Base folder.
- Rename Dockerfile.txt to Dockerfile in all folders except Base.
This will reduce the complexity of the build process and reduce code conflicts between forks, since the Dockerfile only changes if it needs logical updates made to it (instead of generated changes).
This issue would also involve changes to the Makefile to remove references to invocations of generate.sh and to also add in the --build-arg IMAGE_TAG to every docker build command.
Usage example
IMAGE_TAG=4.3.0-20220726 docker build -t selenium/standalone-chrome:${IMAGE_TAG} --build-arg=${IMAGE_TAG} .
The above build command would use FROM selenium/node-chrome:4.3.0-20220726
without needing to modify the Dockerfile or generating a Dockerfile using code.
I verified that the feature works in both docker as well as podman. Are there other container platforms we'd want to verify if this works in?