Smaller Docker image (#622)

* Docker image has been greatly slimmed down and caches node_modules for rebuilds

* Update Dockerfile

* Dockerfile improvements

* Remove devDependencies from final image (#2)

* Remove devDependencies from final image

* Move to single-stage build
This commit is contained in:
Shyam Sunder
2018-09-21 01:10:04 -04:00
committed by John Furrow
parent 03d3943974
commit cedd8bea7a

View File

@@ -1,24 +1,29 @@
FROM node:7.8.0
ARG NODE_IMAGE=node:10.1-alpine
# Install runtime dependencies and remove state generated by apt-get before
# creating intermediate image.
RUN apt-get update && apt-get install -y mediainfo && rm -rf /var/lib/apt/lists/*
FROM ${NODE_IMAGE} as nodebuild
# Create app working directory.
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
# Copy docker configuration file. This allows for specifying common configs with
# just environment variables.
COPY config.docker.js /usr/src/app/config.js
# Generate node_modules
COPY package.json ./package.json
COPY package-lock.json ./package-lock.json
RUN apk add --no-cache --virtual=build-dependencies \
python \
build-base && \
npm install && \
apk del --purge build-dependencies
# Install Dependencies and remove cache to keep image small. This is done in one
# step to keep the cache out of intermediate image.
RUN npm install && npm cache clean --force
# Build static assets and remove devDependencies.
COPY client ./client
COPY shared ./shared
COPY config.docker.js ./config.js
RUN npm run build && \
npm prune --production
COPY server ./server
# Build static assets.
RUN npm run build
# Install runtime dependencies.
RUN apk --no-cache add \
mediainfo
# Hints for consumers of the container.
EXPOSE 3000