[Feature Request] Build args support in Docker container actions #25241
-
Unless I missed it, it does not seem possible today to specify Docker build arguments (i.e. arguments passed when building an action’s container. Being able to specify a “build-args” section in an action metadata file would be nice. Potential scenario: specify the tag of base image with a variable (whose value would be defined in the action metadata file and potentially controlled by inputs or environment variables). |
Beta Was this translation helpful? Give feedback.
Replies: 22 comments 4 replies
-
Hello @yoannchaudet, |
Beta Was this translation helpful? Give feedback.
-
Yes, PLEASE! This is a blocker for something I want to do in an action, and it’s tough to find a non-hacky feeling solution. |
Beta Was this translation helpful? Give feedback.
-
Hi @mchevy422, Please tally an extra vote for this feature on my behalf! For further context, I came across this thread while searching for a way to let the action user select what version of the base image to use for a Docker action. That is, it would default to the base image’s “latest” tag, but something like this step in a job would select a different version tag and build the action using that instead:
And base could be passed back to the Dockerfile build via (for example):
(Could also add a new field to with, but to me it makes more sense that the version would be an input.) Thanks! |
Beta Was this translation helpful? Give feedback.
-
Specifically, I’d like to see the build arg to have access to the git commit of the source repo, for example
Especially when building off of somebody’s “@master” version of the action, would be nice to know the git commit that built it. |
Beta Was this translation helpful? Give feedback.
-
A work around until the feature is implemented is that we use the docker image that creates the action as handrails to create the image that we really want with all the arguments we need. entrypoint.sh example:
For the entrypoint.sh to work correctly it is necessary that the necessary dependencies are installed on the main image to be able to use docker ( I recommend that the main image be an alpine so that it is as light as possible ). NOTE: By main image I mean the image resulting from built the DockerFile referenced in the action.yml file. Here is a simple example of how to do it. https://github.com/JavierZolotarchuk/parameterizable-docker-action-example |
Beta Was this translation helpful? Give feedback.
-
A work around until the feature is implemented is that we use the docker image that creates the action as handrails to create the image that we really want with all the arguments we need. entrypoint.sh example:
For the entrypoint.sh to work correctly it is necessary that the necessary dependencies are installed on the main image to be able to use docker ( I recommend that the main image be an alpine so that it is as light as possible ). NOTE: By main image I mean the image resulting from built the DockerFile referenced in the action.yml file. Here is a simple example of how to do it. https://github.com/JavierZolotarchuk/parameterizable-docker-action-example |
Beta Was this translation helpful? Give feedback.
-
This is needed. Use case: run some code analysis (or any language specific tools) with the same Docker image version as the language version used in the repo (such as running FROM golang:1.13.2 in a repo using Go 1.13.2). The only way to do this is to pass the docker image tag from the Action input to the build-arg. |
Beta Was this translation helpful? Give feedback.
-
I would like to see this as well. In my actions |
Beta Was this translation helpful? Give feedback.
-
I’d like to see this feature as well. My current solution is using
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion from @javierzolotarchuk I managed to get my GitHub action updated with an optional build version argument using the suggestion: https://github.com/zmingxie/packer-ami-builder However, this approach causes one side-effect which we won’t be able to live tail the build log within the GitHub Action web console. Logs will only be accessible after the build is completed. Really hope GitHub will add this feature soon. |
Beta Was this translation helpful? Give feedback.
-
thanks for this nice workaround. it solved my issue though a github actions solution would not require the intermediate container (as you know) and would be much cleaner. things people should be aware of:
you can manually map the various directories and pass env vars. |
Beta Was this translation helpful? Give feedback.
-
i originally tried to solve this with a slightly different approach, using
but that syntax is not accepted. it’s a bit of a mystery to me just where interpolation is allowed and where it is not allowed. ultimately, i ended up using javierzolotarchuk’s solution. |
Beta Was this translation helpful? Give feedback.
-
Also ran into this today, the workarounds don’t work for my use case so we are stuck unfortunately. |
Beta Was this translation helpful? Give feedback.
-
Ran into this issue today. Was wondering how to actually pass ARG in my docker container. Any updates on this ? |
Beta Was this translation helpful? Give feedback.
-
This would be really helpful, especially if it also allows passing --cache-to and --cache-from arguments. |
Beta Was this translation helpful? Give feedback.
-
I tried manually mapping directories and it doesn’t work. |
Beta Was this translation helpful? Give feedback.
-
Hey, any update on the feature request? Would love to see it. I have the exact same use case as mentioned by op. I want to install a dependency inside Dockerfile which needs to have dynamic version (i.e version to be picked up by env). |
Beta Was this translation helpful? Give feedback.
-
This looks to me more like a bug than a feature request. |
Beta Was this translation helpful? Give feedback.
-
Any update on this? This is much needed! |
Beta Was this translation helpful? Give feedback.
-
Would love to see this feature. |
Beta Was this translation helpful? Give feedback.
-
Any updated on this feature request please ? |
Beta Was this translation helpful? Give feedback.
A work around until the feature is implemented is that we use the docker image that creates the action as handrails to create the image that we really want with all the arguments we need.
Basically what we have to do is create a docker image in the entrypoint.sh and run it.
entrypoint.sh example:
For the entrypoint.sh to…