我正在尝试创建一个工作流,使用https://github.com/docker/build-push-action构建 docker 映像并将其推送到 docker hub 。
我有一个具有如下文件夹结构的 monorepo:
project
api
Dockerfile
client
这是工作流程:
name: deploy
on:
push:
branches:
- main
paths:
- "api/**"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: repo/kheilyshad-api:latest
context: .
file: api/Dockerfile
它总是失败并出现此错误:
/usr/bin/docker buildx build --tag ***/kheilyshad-api:latest --iidfile /tmp/docker-build-push-yGQ2mf/iidfile --metadata-file /tmp/docker-build-push-yGQ2mf/metadata-file --file api/Dockerfile --push .
error: could not find api: stat api: no such file or directory
Error: buildx failed with: error: could not find api: stat api: no such file or directory
我必须在根目录中构建 docker 映像,因此我使用file
指定 Dockerfile 的路径。基本上是这样的
docker build -f ./api/Dockerfile .
但它找不到 api 文件夹。我试图将文件设置为./api/Dockerfile
,api
等,但它们都不起作用。