From 14d7996f76a548d3ee49d72d075c656243909252 Mon Sep 17 00:00:00 2001 From: Martin Charles Date: Sat, 2 Dec 2017 22:24:56 -0500 Subject: [PATCH] Updated Dockerfile This does two things: 1. No longer user onbuild. Onbuild is deprecated for [reasons outlined here][reasons]. 2. Build static assets with the container. Before, the static assets wouldn't be built causing the container to crash on start up. [reasons]: https://github.com/docker-library/official-images/issues/2076 --- .dockerignore | 4 ++++ Dockerfile | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..db54b2f6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +# Ignore files not needed for building and running to keep image size low. +.git/ +node_modules/ + diff --git a/Dockerfile b/Dockerfile index 0d22db31..1134e670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,28 @@ -FROM node:7.8.0-onbuild +FROM node:7.8.0 + +# 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/* -COPY config.docker.js config.js + +# 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 + +# 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. +RUN npm run build + +# Hints for consumers of the container. EXPOSE 3000 VOLUME ["/data"] + +# Start application. +CMD [ "npm", "start" ]