Home > Enterprise >  How to run Apollo Graphql Prisma migrate deploy in Dockerfile
How to run Apollo Graphql Prisma migrate deploy in Dockerfile

Time:01-04

Normally duration development I run

yarn prisma migrate dev

Now I create Docker image and run there service using docker-compose.

I have no idea where I put yarn prisma migrate deploy command in Dockerfile.

Dockerfile

FROM node:17 AS BUILD_IMAGE
WORKDIR /usr/src/app
COPY ["package.json", "yarn.lock", "tsconfig.json", "./"]
COPY ["./prisma/schema.prisma", "./prisma/"]
RUN yarn --frozen-lockfile
RUN yarn prisma generate
COPY . .
RUN yarn build
#RUN yarn install --production
RUN yarn autoclean --force

FROM node:17-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY --from=BUILD_IMAGE /usr/src/app/dist ./dist
COPY --from=BUILD_IMAGE /usr/src/app/node_modules ./node_modules
EXPOSE 4000
CMD [ "node", "dist/server.js" ]

CodePudding user response:

I think that this issue is base on Dockerfile. For my case, I copy the package.json and prisma fold then run the script.

Here how I changed the Dockerfile

COPY --from=BUILD_IMAGE /usr/src/app/prisma ./prisma
COPY --from=BUILD_IMAGE /usr/src/app/package*.json ./

EXPOSE 4000
#            
  • Related