I am experimnting in automating parts of a project that I'd ideally deploy and forget about. The project is comprised of an XML parser and a small Flask website. At the moment the folder structure looks like this:
.
├── init.sql
└── parser
├── cloudbuild.yaml
├── cloud_func
│ └── main.py
├── Dockerfile
├── feed_parse.py
├── get_so.py
├── requirements.txt
└── utils.py
Now, I can correctly set up the trigger to look at /parser/cloudbuild.yaml
, but building the image with the following command raises an error:
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
it looks to me that gcp has troubles locating my Dockerfile
which is in the same folder cloudbuild.yaml
is located.
What am I missing?
For the sake of completeness, the Dockerfile looks like this:
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
edit: and the cloudbuild.yaml
I'm using for the build
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]