I created a GitHub action and am passing input arguments to the action. I am using these arguments in a bash script, which is being called by the Dockerfile
. However, it is possible to use any of these inputs in the Dockerfile
?
Specifically I am trying to make the python version a variable input. The Dockerfile
is:
FROM python:3
RUN pip install flake8
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Where I want the first line to be
FROM python:<github_action_input_arg>
First, I suggest you to use docker/build-push-action@v2
. Then in pipeline, you could use next to pass argument from github actions to Dockerfile:
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: $your_account/$your_repo
build-args: |
github_action_input_arg=xxx
Of course, for Dockerfile
, you should change to next:
ARG github_action_input_arg
FROM python:${github_action_input_arg}
You could refers to understand-how-arg-and-from-interact & build-push-action . If you mean you are the owner of your own action, you could also refers to build-push-action
to know how it handle this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.