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
This commit is contained in:
Martin Charles
2017-12-02 22:24:56 -05:00
parent bba07ed3de
commit 14d7996f76
2 changed files with 29 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
# Ignore files not needed for building and running to keep image size low.
.git/
node_modules/
+25 -2
View File
@@ -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" ]