【问题标题】:Concourse: cannot access job resources during put step大厅:在放置步骤期间无法访问作业资源
【发布时间】:2019-06-24 18:05:05
【问题描述】:

我正在尝试创建一个作业并使用 build 参数推送一个包含我的应用程序依赖项的 docker 映像。在大厅文档中,它指出通过get 获取的所有资源在放置步骤期间都可用。但是,我似乎无法访问我的 git 资源,以便从中提取 pom.xml 文件。当我尝试运行此作业时,我收到 pom.xml 文件不存在的错误。

管道作业

  - name: get-dependencies
    plan:
    - get: git-repo
      passed: [pull-repo]
      trigger: true
    - get: artifacts-container
    - put: artifacts-container
      params:
        inputs: [git-repo]
        build: git-repo/app/concourse/dockerfiles/artifacts

Dockerfile

# Set base image qualities
FROM localhost:5000/app-artifacts:0.0.3 AS build

Load application into image
COPY git-repo/app/pom.xml /

RUN mvn dependency:go-offline 

【问题讨论】:

  • 会不会是相对路径问题?也就是说,正在构建的 Dockerfile 位于“git-repo/app/concourse/dockerfiles/artifacts”上,并试图从“git-repo/app/pom.xml”访问某些内容。也许它正在“git-repo/app/concourse/dockerfiles/artifacts”中寻找“git-repo/app/pom.xml”

标签: docker concourse


【解决方案1】:

我遇到了类似的问题。我想构建一个 docker 映像并使用 COPY 命令将来自不同资源的文件夹放入该映像中。

首先,我只给 docker-image-resource 提供了带有 Dockerfile 所在文件夹的“build”参数。但是那样我就无法访问其他资源,我最终使用了“build”和“dockerfile”参数。这样,构建发生在 put 步骤的根目录中,并且所有其他工件都可用。

我的管道:

- put: docker-image-resource
  params:
    build: .
    dockerfile: ./path/to/Dockerfile
    build_args:
      CONFIG_DIR: ./other-resource/

我进一步使用了 build-arg 将 Dockerfile 与管道构建分离。所以我可以在其他构建上下文(例如本地)中指定其他目录。

【讨论】:

    【解决方案2】:

    不确定您的容器是做什么的,但您应该删除 - get: artifacts-container 语句并保留 put

    【讨论】:

      猜你喜欢
      • 2023-01-29
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2018-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多