Reputation: 6572
My project is using node, but I can well imagine other people having a similar idea.
The version of my language-interpreter is controlled in a file (in my case .nvmrc
), which I want to use to select which image my build-command should run in.
When running Docker locally, I use a build-arg to let Docker know what version of an image I want to take:
ARG NODE_VERSION
FROM node:${NODE_VERSION} AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:${NODE_VERSION} AS production
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --only=production
COPY --from=build /usr/src/app/dist ./
CMD ["npm", "run", "start:prod"]
I can run docker build . -t my-project:$BRANCH_NAME --build-arg NODE_VERSION=$(cat .nvmrc)
to build docker.
When running this in the cloud, I could just take an image which runs Docker and have just one step in my yml-file for configuring my Google Cloud Run, but this feels like an extra layer. It seems that Google runs some form or Docker to run my command, which gets me to run Docker to run what I actually want, just because I want this extra flexibility of reading a file to adjusting the docker-image.
Is there another way of achieving this, where I can write some variable which can help me to determine the name of the image for the next step within Google Cloud Run or something similar, or do I just have to live with this overhead I created?
Upvotes: 0
Views: 19