I'm deploying a NodeJS project that uses PostgreSQL with Prisma to Kubernetes. I created the Dockerfile and I'm building the docker image to Docker Hub:
FROM node:lts-slim
WORKDIR /app
# Add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
ENV NODE_ENV=production
RUN apt-get update
# Install Chromium
RUN apt-get install chromium -y
# Install yarn
RUN apt-get install yarn -y
COPY package.json /app/package.json
RUN yarn install --silent
# Add app
COPY . /app
# Generate prisma
RUN yarn run generate
# Build the app
RUN yarn build
EXPOSE 4000
# Start the app
CMD ["yarn", "run", "start"]
I want to use CI/CD, so I would need to check if the PostgreSQL is updated. This can be done with npx prisma migrate resolve --preview-feature
I thought on always running the prisma migrate to check if the DB is updated, since if a new build changes the schema, the DB should reflect it.
Since K8S pods are ephemeral, is it right to add the npx prisma migrate resolve --preview-feature to the start script, so everytime the app starts, it also checks the DB? I don't think running the prisma migrate all the time is good, but what would it be the solution?
Thanks in advance!