Skip to content

Instantly share code, notes, and snippets.

@yacinebenkaidali
Last active August 23, 2022 09:11
Show Gist options
  • Save yacinebenkaidali/06d29255d147fec80dd7fd17f6995b96 to your computer and use it in GitHub Desktop.
Save yacinebenkaidali/06d29255d147fec80dd7fd17f6995b96 to your computer and use it in GitHub Desktop.
Multi stage bulid of a Typescript based nodejs app.
FROM node:alpine as builder
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
# npm run build runs the tsc transpiler
RUN npm run build
FROM node:alpine as prod
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci --only=production
COPY --from=builder /usr/src/app/dist ./dist
CMD ["node", "dist"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment