Thanks to Docker for Mac, it's now possible to run a local development server inside a Docker container. We simply run the container with the local repository mounted as a volume. If we make a change locally, it's automatically updated on the container (thanks to the volume) and we don't have to restart the server.
What we can't figure out is how these images should be built for production. Take this simple Node service as an example:
FROM node:6
# Install the dependencies outside of the application's volume directory
ADD package.json .npmrc /node/
RUN npm install --prefix /node
# Set up the correct paths for the new node modules installation
ENV NODE_PATH /node/node_modules:$NODE_PATH
ENV PATH $PATH:/node/node_modules/.bin
# Create an endpoint to mount the service's repository
VOLUME /runtime
WORKDIR /runtime
# Expose the application's port
EXPOSE 10010
# Start the server
CMD scripts/start
In order to create our production container, we'd really like to ADD
the files instead of mounting a volume. That way we can deploy the image and simply run it. What's the correct way to handle this with Docker?