Skip to content

Instantly share code, notes, and snippets.

@BrychanOdlum
Created October 10, 2019 12:36
Show Gist options
  • Save BrychanOdlum/c18e5000498ac7e2f1fcb789b21e2e5e to your computer and use it in GitHub Desktop.
Save BrychanOdlum/c18e5000498ac7e2f1fcb789b21e2e5e to your computer and use it in GitHub Desktop.
Dockerfile
FROM node:10-alpine AS base
WORKDIR /app
# Add python... because bcrypt...
RUN apk --no-cache add --virtual native-deps \
g++ gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
npm install --quiet node-gyp -g
FROM base AS build
# Copy package config
COPY package.json ./
COPY yarn.lock ./
# First, install prod dependencies for use in release
RUN yarn install --pure-lockfile --production
RUN cp -R node_modules /tmp/node_modules
# And now lets install the dev dependencies
RUN yarn install --pure-lockfile
# Bundle in our app sources/resources
COPY . .
# Test...
RUN yarn test
# Build project (transpilation)
RUN yarn build
FROM base AS release
COPY --from=build /tmp/node_modules ./node_modules
COPY --from=build /app/dist ./dist
COPY --from=build /app/package.json ./
# Expose app port
EXPOSE 8080
# And declare our container's entrypoint
ENTRYPOINT yarn start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment