gpt4 book ai didi

docker - 在嵌套文件夹中使用 cloudbuild.yaml 进行 Cloud Build - 构建失败

转载 作者:行者123 更新时间:2023-12-02 18:27:11 28 4
gpt4 key购买 nike

我正在试验自动化我理想地部署和忘记的项目的部分。该项目由一个 XML 解析器和一个小型 Flask 网站组成。目前文件夹结构如下所示:

.
├── init.sql
└── parser
├── cloudbuild.yaml
├── cloud_func
│   └── main.py
├── Dockerfile
├── feed_parse.py
├── get_so.py
├── requirements.txt
└── utils.py

现在,我可以正确设置触发器来查看 /parser/cloudbuild.yaml ,但使用以下命令构建镜像会引发错误:
build . --build-arg "CLIENT_CERT=$CSQL_CERT CLIENT_KEY=$CSQL_KEY SERVER_CA=$CSQL_CA SERVER_PW=$CSQL_PW SERVER_HOST=$CSQL_IP" -t gcr.io/and-reporting/appengine/so-parser:latest
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1

在我看来 gcp 无法找到我的 Dockerfile位于同一文件夹 cloudbuild.yaml位于。
我错过了什么?

为完整起见,Dockerfile 如下所示:
FROM python:3.7-alpine

RUN apk update \
&& apk add gcc python3-dev musl-dev libffi-dev \
&& apk del libressl-dev \
&& apk add openssl-dev

COPY requirements.txt /
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

ADD . /parser
WORKDIR /parser/
RUN mkdir -p certs

# Set env variables from secrets
ARG CLIENT_CERT
ENV CSQL_CERT=${CLIENT_CERT}

ARG CLIENT_KEY
ENV CSQL_KEY=${CLIENT_KEY}

ARG SERVER_CA
ENV CSQL_CA=${SERVER_CA}

ARG SERVER_PW
ENV CSQL_PW=${SERVER_PW}

ARG SERVER_HOST
ENV CSQL_IP=${SERVER_HOST}

# Get ssl certs in files
RUN echo $CLIENT_CERT > ./certs/ssl_cert.pem \
&& echo $CLIENT_KEY > ./certs/ssl_key.pem \
&& echo $SERVER_CA > ./certs/ssl_ca.pem

CMD python get_so.py

编辑 : 和 cloudbuild.yaml我正在用于构建
steps:

# Building image
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-f',
'Dockerfile',
'--build-arg',
'CLIENT_CERT=$$CSQL_CERT CLIENT_KEY=$$CSQL_KEY SERVER_CA=$$CSQL_CA SERVER_PW=$$CSQL_PW SERVER_HOST=$$CSQL_IP',
'-t',
'gcr.io/$PROJECT_ID/appengine/so-parser:latest',
'.'
]
secretEnv: ['CSQL_CERT', 'CSQL_KEY', 'CSQL_CA', 'CSQL_PW', 'CSQL_IP']

# Push Images
# - name: 'gcr.io/cloud-builders/docker'
# args: ['push', 'gcr.io/$PROJECT_ID/appengine/so-parser:latest']

secrets:
- kmsKeyName: projects/myproject/locations/global/keyRings/so-jobs/cryptoKeys/board
secretEnv:
CSQL_CERT: [base64 string]
CSQL_KEY: [base64 string]
CSQL_CA: [base64 string]
CSQL_PW: [base64 string]
CSQL_IP: [base64 string]

最佳答案

因为您的 cloudbuild.yaml 中的点文件,docker 无法找到 Dockerfile这是在 parser目录:

steps:

- name: "gcr.io/cloud-builders/docker"

args: ["build", "-t", "gcr.io/$PROJECT_ID/mynodejs:$SHORT_SHA", "./parser"]

关于docker - 在嵌套文件夹中使用 cloudbuild.yaml 进行 Cloud Build - 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59375550/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com