Indeed, the build process will be slow especially on the 1st run. This is because our Dockerfile uses the base image "ruby:2.5.1-slim". This base image itself consists of many other images that include individual parts of the system (like its slim OS).
Docker is smart in that it creates a "reusable layer" for each line in your Dockerfile. It is also intelligent enough to detect if you made changes in your system with respect to those commands. If no change has been made with respect to that line in your Dockerfile, it just reuses that layer as part of your image.
Also, ran for the 1st time, it also runs the 2nd command in the Dockerfile: RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs libsqlite3-dev. This updates apt and install critical dependencies. This indeed takes awhile. In one of the demoes I did, it downloaded 250MB worth of packages from the internet.
After the 1st run, all you change is your code (and maybe adding Gems in your Gemfile here and there). Your docker build will hopefully be much faster (unless you changed a big part of your app).
As per Sidekiq and Web having separate images, it might be that they are just tagged under different names. You can check if their image hash (it looks like this: c12dasd21c) are the same. If they are, they are using the same image. And even if they are using different images, you can check that they use command Docker image layers via docker history <chash> and they have at least some common docker image layers.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Adding
sidekiq
andweb
at docker-compose.yml will build twice when you rundocker-compose build
The building process is slow. Is there anything can we improve here?
Hi Allen, that's an interesting observation.
Indeed, the build process will be slow especially on the 1st run. This is because our Dockerfile uses the base image "ruby:2.5.1-slim". This base image itself consists of many other images that include individual parts of the system (like its slim OS).
Docker is smart in that it creates a "reusable layer" for each line in your Dockerfile. It is also intelligent enough to detect if you made changes in your system with respect to those commands. If no change has been made with respect to that line in your Dockerfile, it just reuses that layer as part of your image.
Also, ran for the 1st time, it also runs the 2nd command in the Dockerfile:
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs libsqlite3-dev
. This updates apt and install critical dependencies. This indeed takes awhile. In one of the demoes I did, it downloaded 250MB worth of packages from the internet.After the 1st run, all you change is your code (and maybe adding Gems in your Gemfile here and there). Your
docker build
will hopefully be much faster (unless you changed a big part of your app).As per Sidekiq and Web having separate images, it might be that they are just tagged under different names. You can check if their image hash (it looks like this: c12dasd21c) are the same. If they are, they are using the same image. And even if they are using different images, you can check that they use command Docker image layers via
docker history <chash>
and they have at least some common docker image layers.