Created
March 10, 2025 13:09
-
-
Save tiagopog/599cb8de2df607a15ca4ef1c2ffe4753 to your computer and use it in GitHub Desktop.
Production Dockerfile: Node.js + TypeScript + Prisma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:20-alpine AS build | |
RUN apk update && apk add curl libcurl | |
RUN mkdir -p /home/node/app/node_modules | |
WORKDIR /home/node/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
RUN npx prisma generate | |
RUN npx tsc | |
FROM node:20-alpine | |
ENV NODE_ENV="production" | |
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app | |
WORKDIR /home/node/app | |
USER node | |
COPY --chown=node:node package*.json ./ | |
RUN npm install --only=production --quiet | |
COPY --from=build --chown=node:node /home/node/app/build . | |
COPY --from=build --chown=node:node /home/node/app/node_modules/.prisma ./node_modules/ | |
COPY --from=build --chown=node:node /home/node/app/src/models/migrations ./src/models/migrations | |
COPY --from=build --chown=node:node /home/node/app/src/models/schema.prisma ./src/models/schema.prisma | |
RUN npx prisma generate | |
EXPOSE 3000 | |
CMD [ "node", "src/web/index.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment