我有一个项目,我打算用wercker构建和发布多个Docker映像。每个项目的源代码都位于项目内各自的文件夹中。
作为一个简单的示例,我创建了一个repository,您可以在其中重现此问题。我使用了wercker's internal/docker-build。显然,在链接中有一个上下文属性context
,但似乎没有作用:上下文似乎仍然是我项目的根。
我的文件夹结构:
我的wercker.yml文件:
box:
id: python:2.7-slim
ports:
- "5000"
build:
steps:
- internal/docker-build:
dockerfile: flask-app/Dockerfile
context: flask-app
image-name: flask-app
当我在项目根目录中运行wercker build --pipeline build
时,输出:
--> No Docker host specified, checking: /var/run/docker.sock
--> Executing pipeline
--> Copying working directory to: /home/handris/Projects/wercker-context/.wercker/projects/wercker-context
--> Copied working directory: 0.00s
--> Running step: setup environment
Pulling from library/python: 2.7-slim
Digest: sha256:df3ba9998242864e650d62d158685c3c7af8c4f3ae1545bdc38780473b0b6c55
Status: Image is up to date for python:2.7-slim
--> Copying source to container
--> Running step: wercker-init
--> Running step: docker build
Step 1/7 : FROM python:3.6-alpine
Pulling from library/python: 3.6-alpine
Digest: sha256:4ae5142f052c4efd0bede8483f8ca43a73e8fcfce5dbf8f581967c2c9bac597b
Status: Image is up to date for python:3.6-alpine
---> 1837080c5e87
Step 2/7 : ENV PYTHONUNBUFFERED=1
---> Using cache
---> c4a790b9c973
Step 3/7 : WORKDIR /app
---> Using cache
---> 69ff1c48b2ac
Step 4/7 : COPY requirements.txt requirements.txt
--> Steps passed: 5.60s
--> Pipeline finished: 5.80s
它无法复制与Dockerfile相同文件夹中的我的requirements.txt。
我的巫师版本:
wercker version 1.0.1216 (Compiled at: 2018-05-01T13:14:48Z, Git commit: 426a99095ec0c95391620319833338afd1ccbc74)
我想念的是什么?如何使context
属性与internal/docker-build
一起使用?
编辑:
我还尝试了在没有dockerfile
属性的情况下运行构建,如下所示:
- internal/docker-build:
context: flask-app
image-name: flask-app
在这种情况下,输出:
--> No Docker host specified, checking: /var/run/docker.sock
--> Executing pipeline
--> Copying working directory to: /home/handris/Projects/wercker-context/.wercker/projects/wercker-context
--> Copied working directory: 0.00s
--> Running step: setup environment
Pulling from library/python: 2.7-slim
Digest: sha256:df3ba9998242864e650d62d158685c3c7af8c4f3ae1545bdc38780473b0b6c55
Status: Image is up to date for python:2.7-slim
--> Copying source to container
--> Running step: wercker-init
--> Running step: docker build
ERROR Failed to build image: Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
--> Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
--> Step failed: docker build Error response from daemon: Cannot locate specified Dockerfile: Dockerfile 0.28s
--> Pipeline failed: 3.40s
FATAL Step failed: docker build
我还尝试仅指定dockerfile
属性,例如:
steps:
- internal/docker-build:
dockerfile: flask-app/Dockerfile
image-name: flask-app
在这种情况下,我的控制台输出与第一种情况相同。