Skip to content

Instantly share code, notes, and snippets.

@vschoener
Last active April 29, 2020 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vschoener/dcaf7af1c4bafa3a88e42d3ee5781047 to your computer and use it in GitHub Desktop.
Save vschoener/dcaf7af1c4bafa3a88e42d3ee5781047 to your computer and use it in GitHub Desktop.
Multi Stage docker file example with NODE
#
# Builder stage.
# This state compile our TypeScript to get the JavaScript code
#
FROM node:12.13.0 AS builder
WORKDIR /usr/src/app
COPY package*.json ./
COPY tsconfig*.json ./
COPY ./src ./src
RUN npm ci --quiet && npm run build
#
# Production stage.
# This state compile get back the JavaScript code from builder stage
# It will also install the production package only
#
FROM node:12.13.0-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY package*.json ./
RUN npm ci --quiet --only=production
## We just need the build to execute the command
COPY --from=builder /usr/src/app/build ./build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment