Git Product home page Git Product logo

node-app-docker-layers's Introduction

This app is a demonstration of the Docker Image layering. If you checkout the first commit and run make build you should get the first version of the Docker image built. Then, change to the second commit and run make build again, you should see an output pretty much like this:

make build
docker build -t tonysm/node-app-docker:2.0.0 .
Sending build context to Docker daemon  2.065MB
Step 1/8 : FROM node:13.3.0
 ---> 2af77b226ea7
Step 2/8 : WORKDIR /app
 ---> Using cache
 ---> 07c5be8e9cde
Step 3/8 : RUN apt-get update && apt-get install -y git
 ---> Using cache
 ---> 9285fc2a80c2
Step 4/8 : COPY package.json package-lock.json /app/
 ---> Using cache
 ---> b5fb084d0c2a
Step 5/8 : RUN npm ci
 ---> Using cache
 ---> 19482a7d821a
Step 6/8 : COPY . /app
 ---> e1e469c7e35c
Step 7/8 : EXPOSE 3000
 ---> Running in 3f19795b571f
Removing intermediate container 3f19795b571f
 ---> ad14d5378b2d
Step 8/8 : CMD ["npm", "run", "serve"]
 ---> Running in dfa2ff542a49
Removing intermediate container dfa2ff542a49
 ---> 280c53c0f03d
Successfully built 280c53c0f03d
Successfully tagged tonysm/node-app-docker:2.0.0

Notice the Using cache messages. That means that it didn't have to rebuild everything from scratch, only the steps from 6/8 and below are rebuilt.

Your Dockerfile steps should follow something like:

  • OS-level dependencies installation;
  • App-level dependencies installtion;
  • Copy source code to container.

Usually, more often than not you are releasing only source code changes. If you added a new app dependency, you probably added source code that uses it, so rebuilding from the NPM steps here would be ok. If you added any OS-level dependency, chances are that's because you needed it for some kind of package at the app-level dependency, and you also had to change source code, so rebuilding from the top makes sense.

node-app-docker-layers's People

Contributors

tonysm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.