[英]Is there a way to set path for docker build with the github action plugin docker/build-push-action@v1
I have a docker build action as below我有一个 docker build 操作,如下所示
- name: build-push
uses: docker/build-push-action@v1
with:
username: ${{ DOCKER_USERNAME }}
password: ${{ DOCKER_PASSWORD }}
repository: <repo>
tags: tag
push: true
dockerfile: ./<path-to-dockerfile>/Dockerfile
The dockerfile has instructions to ADD few files to the docker image as below dockerfile 有向 docker 镜像添加几个文件的说明,如下所示
ADD file1 .
ADD file2 .
ADD file3 .
the structure of github is: github的结构是:
-.github
-folder1------------
|
folder2-------------
|
-----------------------docker--------
| | | |
file1 file2 file3 Dockerfile
The issue is that the GitHub action is unable to find file1 , file2 and file3 as it is looking in the level of folder1 .问题是 GitHub 操作无法找到file1 、 file2和file3 ,因为它在folder1级别中查找。 The error generated is
产生的错误是
ADD failed: file not found in build context or excluded by .dockerignore: file1: file does not exist
I do not want to modify the path in dockerfile as ADD ./folder1/folder2/file1 .
我不想将 dockerfile 中的路径修改为
ADD ./folder1/folder2/file1 .
. . So how do I add path or change directory from the GitHub Action part using docker/build-push-action@v1 ?
那么如何使用 docker/build-push-action@v1 从 GitHub Action 部分添加路径或更改目录?
Instead of using docker/build-push-action@v1 use docker/build-push-action@v2 as v1 is an older version.不要使用 docker/build-push-action@v1 使用 docker/build-push-action@v2 因为 v1 是旧版本。 Modify the GitHub action as below
修改GitHub动作如下
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }
password: ${{ secrets.DOCKER_PASSWORD }}
- name: build-push
uses: docker/build-push-action@v1
with:
context: ./folder1/folder2/docker/
tags: tag
push: true
dockerfile: ./<path-to-dockerfile>/Dockerfile
using context with the github action will solve this issue.将上下文与 github 操作一起使用将解决此问题。 Context is available only with v2 verison.
上下文仅适用于 v2 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.