Created
January 28, 2019 04:35
-
-
Save zbal/d4dd88e3f5db92d1934a24a0c9d6875f to your computer and use it in GitHub Desktop.
Dockerfile - Multi step build process for node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# One single Dockerfile with a multi step build process | |
# 1. build all native extensions, dependencies, etc. | |
# 2. copy resulting files into a clean container | |
FROM node:10-alpine as builder | |
# Add core packages to allow building native extensions | |
RUN apk add --no-cache make gcc g++ python | |
RUN npm install -g yarn | |
WORKDIR /src | |
COPY package.json yarn.lock /src/ | |
RUN yarn install --production | |
COPY . /src | |
FROM node:10-alpine | |
RUN npm install -g pm2 | |
WORKDIR /app | |
COPY --from=builder /src/ /app/ | |
USER node | |
EXPOSE 3000 | |
CMD [ "pm2-docker", "--json", "--instances", "0", "server/server.js" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment