Skip to content

Instantly share code, notes, and snippets.

@wodCZ
Created August 2, 2022 13:25
Show Gist options
  • Save wodCZ/447bd4639f621d72d5e17c6a4e86dcde to your computer and use it in GitHub Desktop.
Save wodCZ/447bd4639f621d72d5e17c6a4e86dcde to your computer and use it in GitHub Desktop.
Nest.js + Prisma Dockerfile - possibly smallest image size
FROM node:18-alpine as build
WORKDIR /app
RUN yarn global add @vercel/ncc
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN ./node_modules/.bin/prisma generate && yarn run build && ncc build dist/src/main.js -o build
FROM node:18-alpine as production
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV
ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT
WORKDIR /app
COPY --chown=node:node --from=build /app/build ./
USER node
CMD [ "node", "index.js" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment