To deploy an express node.js api in production I wanted to use kubernetes These steps were followed:
- created cluster in google cloud
- clone the code to the cluster from git
- docker build -t gcr.io/[GCLOUDID]/app:v1 .
- docker pushgcr.io/[GCLOUDID]/app:v1
- kubectl run app --image=gcr.io/[GCLOUDID]/app:v1
This runs fine, but when i want to update the code, i'm kinda lost. i tried to build a v2(docker build -t gcr.io/[GCLOUDID]/app:v2 . ) and setting the image via kubectl set image deployments/app app=gcr.io/[GCLOUDID]/app:v2
this method throws all kind of errors(imagepullbackoff, crashloopbackoff for example)
this dockerfile was used:
FROM node:11-alpine
WORKDIR /
COPY . /
RUN rm -rf node_modules
RUN rm -rf package-lock.json
RUN apk update && apk upgrade \
&& apk add --no-cache git \
&& apk --no-cache add --virtual builds-deps build-base python \
&& npm rebuild bcrypt --build-from-source
# Install imagemagick with support to native library
RUN apk add --no-cache file
RUN apk --update add imagemagick
RUN npm install
ENV TYPE=docker
EXPOSE 80
CMD [ "npm", "start" ]