Skip to content

Instantly share code, notes, and snippets.

@evzpav
Last active March 24, 2023 03:30
Show Gist options
  • Save evzpav/14598d3eb93e5c77c6875860d14a0267 to your computer and use it in GitHub Desktop.
Save evzpav/14598d3eb93e5c77c6875860d14a0267 to your computer and use it in GitHub Desktop.
Dockerfile Nest project
# ---- Base Node ----
FROM node:19-alpine3.16 AS base
ENV NODE_ENV=development
RUN mkdir /app && chown -R node:node /app
WORKDIR /app
USER node
RUN npm set progress=false && npm config set depth 0
# ---- Dependencies ----
FROM base AS dependencies
WORKDIR /app
COPY --chown=node:node package*.json ./
RUN npm ci && npm cache clean --force
# ---- Build ----
FROM dependencies AS build
WORKDIR /app
COPY --chown=node:node . /app/
RUN npm run build
# ---- Release ----
FROM build AS image
WORKDIR /app
COPY --chown=node:node ./dist ./dist
ENV NODE_ENV=production
CMD node dist/src/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment