我正在尝试使我理想地部署并忘记的项目部分自动化。该项目由一个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]
答案 0 :(得分:1)
由于cloudbuild.yaml
文件中的点,docker无法找到Dockerfile
目录中的parser
:
steps:
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/mynodejs:$SHORT_SHA", "./parser"]
答案 1 :(得分:0)
如果你想提及 dockerfile 名称: 步骤:
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/mynodejs:$SHORT_SHA", "-f", "./parser/your-dockerfile"]