mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
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:
committed by
John Furrow
parent
03d3943974
commit
cedd8bea7a
35
Dockerfile
35
Dockerfile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user