Concourse将任务放入Docker-Image资源中。 build_args尚未传递给Dockerfile

发布于 2025-01-27 04:38:23 字数 2135 浏览 2 评论 0原文

当以下大厅管道build_args未使用/传递到docker build阶段时,我有一个情况。管道在下面的一个:

 name: project
  type: git
  check_every: 1m
  source:
    uri: ((project-url))
    branch: ((project-branch))
    private_key: ((github-private-key))
    paths: [ ((context))/* ]

- name: registry
  type: docker-image
  source:
    username: ((art_user))
    password: ((art_token))
    repository: docker.artifactory......

... ...

jobs:

- name: publish
  serial: true
  plan:
  - in_parallel:
    - get: project
     ... ...
  - put: build
    resource: registry
    params:
      build: project/((context))
      build_args:
        a_user: ((art_user))
        a_token: ((art_token))
        testArg: "testing"

dockerfile在上下文目录中具有以下内容。 我从中删除了任何细节。

FROM docker.artifactor.../debian:buster

#####################

ARG a_user
ARG a_token
ARG testArg
RUN echo "a_user: $a_user"
RUN echo "a_token: $a_token"
RUN echo "testArg: $testArg"
RUN env

问题是这些变量在构建时间期间具有空值。 以下是示例运行:

Status: Downloaded newer image for docker.artifactory..../debian:buster
 ---> 26a2b081e032
Step 4/38 : ARG a_user
 ---> Running in 6d48933458d9
Removing intermediate container 6d48933458d9
 ---> d2913609be9e
Step 5/38 : ARG a_token
 ---> Running in 1b94c1795d8c
Removing intermediate container 1b94c1795d8c
 ---> 8bc2f65677ca
Step 6/38 : ARG testArg
 ---> Running in 88c088363349
Removing intermediate container 88c088363349
 ---> 810a481ad166
Step 7/38 : RUN echo "a_user: $a_user"
 ---> Running in 901423ea11b6
a_user: 
Removing intermediate container 901423ea11b6
 ---> 58e18ab30dbc
Step 8/38 : RUN echo "a_token: $a_token"
 ---> Running in 95e9239bbceb
a_token: 
Removing intermediate container 95e9239bbceb
 ---> ce2df5ea1a36
Step 9/38 : RUN echo "testArg: $testArg"
 ---> Running in 7443e6da424e
testArg: 
Removing intermediate container 7443e6da424e
 ---> 46ab83d6f94f
Step 10/38 : RUN env
 ---> Running in 4f780b89f7ee
no_proxy=...
HOSTNAME=1f790b89f7ea
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/

您能在这里提供帮助吗?

I have a case when the following Concourse pipeline build_args are not used/passed to docker build phase. The pipeline looks like below one:

 name: project
  type: git
  check_every: 1m
  source:
    uri: ((project-url))
    branch: ((project-branch))
    private_key: ((github-private-key))
    paths: [ ((context))/* ]

- name: registry
  type: docker-image
  source:
    username: ((art_user))
    password: ((art_token))
    repository: docker.artifactory......

... ...

jobs:

- name: publish
  serial: true
  plan:
  - in_parallel:
    - get: project
     ... ...
  - put: build
    resource: registry
    params:
      build: project/((context))
      build_args:
        a_user: ((art_user))
        a_token: ((art_token))
        testArg: "testing"

Dockerfile in the context directory has the following content.
I remove any specifics from it.

FROM docker.artifactor.../debian:buster

#####################

ARG a_user
ARG a_token
ARG testArg
RUN echo "a_user: $a_user"
RUN echo "a_token: $a_token"
RUN echo "testArg: $testArg"
RUN env

Issue is these variables have empty values during build time.
Below is a sample run:

Status: Downloaded newer image for docker.artifactory..../debian:buster
 ---> 26a2b081e032
Step 4/38 : ARG a_user
 ---> Running in 6d48933458d9
Removing intermediate container 6d48933458d9
 ---> d2913609be9e
Step 5/38 : ARG a_token
 ---> Running in 1b94c1795d8c
Removing intermediate container 1b94c1795d8c
 ---> 8bc2f65677ca
Step 6/38 : ARG testArg
 ---> Running in 88c088363349
Removing intermediate container 88c088363349
 ---> 810a481ad166
Step 7/38 : RUN echo "a_user: $a_user"
 ---> Running in 901423ea11b6
a_user: 
Removing intermediate container 901423ea11b6
 ---> 58e18ab30dbc
Step 8/38 : RUN echo "a_token: $a_token"
 ---> Running in 95e9239bbceb
a_token: 
Removing intermediate container 95e9239bbceb
 ---> ce2df5ea1a36
Step 9/38 : RUN echo "testArg: $testArg"
 ---> Running in 7443e6da424e
testArg: 
Removing intermediate container 7443e6da424e
 ---> 46ab83d6f94f
Step 10/38 : RUN env
 ---> Running in 4f780b89f7ee
no_proxy=...
HOSTNAME=1f790b89f7ea
HOME=/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/

Could you please help here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2025-02-03 04:38:23

您粘贴的管道已被严重编辑,以至于我完全无法解决问题,但是我注意到的一件事是图像资源被命名为“注册表”,但提照是指build> build> build资源(?!)。 注册表资源 param引用,这似乎不是合法的参数

追溯您的步骤。使用以下最小可行管道设置作为指导:

给定以下Dockerfile,请code-repo/docker/dockerfile

FROM ubuntu:bionic

ARG HELLO
RUN echo $HELLO
RUN sleep 100

和一个最小管道,如下所示:

resources:
  - name: code-repo
    type: git
    source:
      branch: main
      uri: [email protected]:my/repo.git
      private_key: ((repo_key))

  - name: my-docker-image
    type: docker-image
    source:
      repository: oozie/my-docker-image
      tag: latest
      username: ((docker_username))
      password: ((docker_password))


jobs:
  - name: publish-image
    plan:
    - get: code-repo
    - put: my-docker-image
      params:
        build: code-repo/docker
        build_args:
          HELLO: world

我会看到我的hello 在构建中构建ARG:

The pipeline you pasted has been edited down too heavily for me to put a finger on exactly what's wrong, but one thing I notice is that the image resource is named 'registry' but the put refers to the build resource (?!). The registry is referenced by a resource param, which doesn't seem to be a legit param.

Retrace your steps. Use the following minimal viable pipeline setup as a guide:

Given the following dockerfile at code-repo/docker/Dockerfile

FROM ubuntu:bionic

ARG HELLO
RUN echo $HELLO
RUN sleep 100

and a minimal pipeline that looks as follows:

resources:
  - name: code-repo
    type: git
    source:
      branch: main
      uri: [email protected]:my/repo.git
      private_key: ((repo_key))

  - name: my-docker-image
    type: docker-image
    source:
      repository: oozie/my-docker-image
      tag: latest
      username: ((docker_username))
      password: ((docker_password))


jobs:
  - name: publish-image
    plan:
    - get: code-repo
    - put: my-docker-image
      params:
        build: code-repo/docker
        build_args:
          HELLO: world

I am getting seeing my HELLO build arg in the build:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文