1

我有一个项目,我打算用 wercker 构建和发布多个 Docker 镜像。每个项目的源代码都位于项目内的单独文件夹中。

作为一个更简单的示例,我创建了一个存储库,您可以在其中重现此问题。我使用了wercker 的 internal/docker-build。在链接中很明显有一个上下文属性context,但它似乎没有效果:上下文似乎仍然是我项目的根源。

我的文件夹结构:

  • 根:
    • 烧瓶应用
      • 应用程序.py
      • 要求.txt
      • Dockerfile
    • wercker.yml

我的 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 版本:

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

在这种情况下,我的控制台输出与第一种情况相同。

4

0 回答 0