Skip to content

Instantly share code, notes, and snippets.

@InclinedScorpio
Created January 11, 2022 19:34
Show Gist options
  • Save InclinedScorpio/0dab33b783cb84cd7eb02985dc10df4e to your computer and use it in GitHub Desktop.
Save InclinedScorpio/0dab33b783cb84cd7eb02985dc10df4e to your computer and use it in GitHub Desktop.
Nodejs Typescript Dockerfile
# stage 1 building the code, dev dependencies will be required (convert TS -> JS)
FROM node as builder
WORKDIR /usr/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# stage 2, now as build is created, copy it from stage 1 and use it with prod dependencies
FROM node
WORKDIR /usr/app
COPY package*.json ./
RUN npm install --production
COPY --from=builder /usr/app/dist ./dist
COPY .env .
EXPOSE 4000
CMD node dist/src/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment