add support for build-args
Signed-off-by: Avi Deitcher [email protected]
- What I did
Added support for --build-arg to lkt pkg build, passing them on to docker build --build-arg
- How I did it
Added the command option to the pkg build flagSet, and then creating WithBuildArg() options
- How to verify it
Run it with and without the --build-arg
- Description for the changelog
Support for --build-arg
One of the key concepts behind the linuxkit package is that the build entirely depends on files checked into a git repository (with the git commit and repository being recorded in the package meta-data) and signed files from docker hub for the build. The tag of the resultant image is actually the content hash of all the bits which were used to build the image (source and dockerfile with the dockerfile containing the explicit version of the image used to build the image). This PR seems to add the ability to change the build based on command line arguments passed into the build which is a) not recorded and b) does not change the tag.
Correct. We (you and I and some others) had discussed this verbally a while back. I wanted to raise the discussion again.
This really has its roots in the docker build debate (years ago) about whether or not to include --build-arg for roughly the same reason. If I recall correctly, they ended up including it because practically won. It was just too necessary. Without it, you end up doing some really convoluted things that don't end up helping, like having a template file for the dockerfile checked in, adding the dockerfile to gitignore, and then generating the dockerfile separately prior to running lkt pkg build.
At a certain point we end up running against what people practically need to do.
I'm coming down (obviously) on the docker-historical side of needing build args - in the end, lkt pkg build is just a fancy wrapper around docker build - but I would like to have the conversation here.
I want to reopen this discussion. I have had several conversations over the years (including recently) where people ask, "how do I pass build args?" When the response is, "you cannot other than in the build.yaml, they do things like described above: make build.yaml.in, check that into git, then generate build.yaml (which is in .gitignore) and wrap our lkt build with their own make magic or similar.
Are we at the point where we should support it? Or maybe at least a build args file (like an env file)? Let users decide whether or not to check that in?