【问题标题】:GCP Cloud Build via trigger: Dockerfile not found通过触发器进行 GCP 云构建:找不到 Dockerfile
【发布时间】:2023-01-26 22:31:32
【问题描述】:

我尝试通过从 Gitlab 调用的 webhook 在 GCP Cloud Build 上触发构建 Docker 映像。 webhook 有效,但是当我运行 docker build 时生成过程停止并出现此错误:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory

此步骤的 YAML 是:

  - name: gcr.io/cloud-builders/docker
    args:
      - build
      - '-t'
      - '${_ARTIFACT_REPO}'
      - .

我稍后通过substitutions提供变量_ARTIFACT_REPO。

我的 Gitlab 存储库包含根级别的 Dockerfile。所以回购结构是:

app/
.gitignore
Dockerfile
README.md
requirements.txt

报错提示找不到Dockerfile,但我不明白为什么会这样。非常感谢您的帮助!

【问题讨论】:

    标签: docker google-cloud-platform gitlab cicd google-cloud-build


    【解决方案1】:

    刚刚解决了这个问题:

    我遵循了 GCP 文档 (link),其中在云构建中包含了这两个步骤:

    - name: gcr.io/cloud-builders/git
      args:
        - clone
        - '-n'
        - 'git@gitlab.com/GITLAB_REPO'
        - .
      volumes:
        - name: ssh
          path: /root/.ssh
    - name: gcr.io/cloud-builders/git
      args:
        - checkout
        - $_TO_SHA
    

    因为我不需要特定的签出,所以我删除了其中的第二步,但我在第一步中忽略了 -n flag,它阻止签出克隆的 repo。

    所以我刚刚删除了 - '-n' 并解决了问题。

    【讨论】:

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