I have a backend service that I’ll need to deploy to
Google Cloud Run.
From Google’s tutorial on Cloud Run, we get that:
First you need to build your image and send it to Cloud Build.
gcloud builds submit --tag gcr.io/PROJECT-ID/helloworld
Only then you deploy it to Cloud Run:
gcloud run deploy --image gcr.io/PROJECT-ID/helloworld --platform managed
I get the sequence above. But I’ll be deploying this service to 2 different environments:
So I need an
SERVER_ENV variable, that should be
"PROD" on my production environment, and of course it should be
"TEST" on my test environment. This is so my server (express server that will be run from the container) knows which database to connect to.
But the problem is that I only have a single
FROM node:12-slim ENV SERVER_ENV=PROD WORKDIR / COPY ./package.json ./package.json COPY ./distApp ./distApp COPY ./distService ./distService COPY ./public ./public RUN npm install ENTRYPOINT npm start
So how can I set different
ENV variables while following the build & deploy sequence above? Is there an option in the
gcloud builds submit comment that I can maybe override something? Or use a different
Dockerfile? Anybody got other ideas?
Maybe use the Cloud Build configuration file?
Source: Docker Questions