Skip to content

Instantly share code, notes, and snippets.

@joshourisman
Created September 14, 2017 22:13
Show Gist options
  • Save joshourisman/d1ef59f88d3a49ecbc9abb4600e2d766 to your computer and use it in GitHub Desktop.
Save joshourisman/d1ef59f88d3a49ecbc9abb4600e2d766 to your computer and use it in GitHub Desktop.
# Install only runtime dependencies.
FROM node:8.5-alpine AS base
RUN apk add --no-cache build-base python
COPY package.json.tmp ./package.json
COPY yarn.lock ./
ENV NODE_ENV production
RUN yarn --pure-lockfile --production=true
# Build the app.
FROM node:8.5-alpine AS build
RUN apk add --no-cache build-base python
COPY package.json.tmp ./package.json
COPY yarn.lock ./
ENV NODE_ENV development
COPY --from=base /node_modules ./node_modules
RUN yarn --pure-lockfile --production=false
COPY . ./
RUN yarn build
# Use runtime dependencies and built app.
FROM node:8.5-alpine
ENV NODE_ENV production
WORKDIR /app
COPY --from=base /node_modules ./node_modules
COPY --from=build /build ./
RUN addgroup -S -g 1001 app \
&& adduser -S -D -h /app -u 1001 -G app app
USER app
CMD ["node", "/app/server/main.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment