Created
September 25, 2015 18:10
-
-
Save puppybits/8c518c4e8964f18cea93 to your computer and use it in GitHub Desktop.
Super fast JS Docker images by caching NPM modules that haven't changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM library/node | |
MAINTAINER [email protected] | |
RUN mkdir /.npm | |
RUN mkdir /app | |
# cache (and skip if no changes) to the node_modules | |
WORKDIR /.npm | |
ADD package.json /.npm/package.json | |
# Set the version in the cache folder to 0. | |
# This is so that Docker will skip downloading node_modules when the version of the app increments but the node_modules do not. | |
RUN npm version 0.0.0 | |
# npm takes a while and we should see progress. This should only happen with a library module changes | |
RUN npm install --production --loglevel verbose | |
# Copy over the app and build with Webpack | |
WORKDIR /app | |
ADD package.json /app/package.json | |
ADD src /app/src | |
ADD server /app/server | |
ADD webpack.config.js /app/webpack.config.js | |
# React/Webpack is based off of Megatome (https://github.com/Levelmoney/generator-megatome) | |
ADD webpack.dist.config.js /app/webpack.dist.config.js | |
RUN npm run build | |
COPY server /app/server | |
EXPOSE 8080 | |
CMD PORT=8080 node --harmony server/server.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment