Speed up NPM install in Docker container

This method works like magic:

https://blog.playmoweb.com/speed-up-your-builds-with-docker-cache-bfed14c051bf

Docker has a special way of caching things for you, and apparently it’s best to use the inborn caching ability.

Cannot say I completely understand how it works, but it does work.

If you follow this pattern, it will work for you:

FROM mhart/alpine-node:5.6.0
WORKDIR /src

# Expose the port 3000
EXPOSE 3000

# Set the default command to run when a container starts
CMD ["node", "server.js"]

# Install app dependencies
COPY package.json /src
RUN npm install

# Copy your code in the docker image
COPY . /src

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)