You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an Osmosis engineer, I would like to reduce the number of layers needed to be rebuilt on a small change so that I can be more productive when working on tasks.
Task 2.1 - Only COPY the desired components in Dockerfile
Currently, in most of our Dockerfiles, we copy the entire repository:
While this might seem convenient, it increases development time by requiring the entire repository to be copied every time one makes a small change.
It requires all subsequent layers to be rebuilt as well, further increasing the waiting time.
This is particularly frustrating when making changes to Dockerfiles that build the image. For example, a Dockerfile that the Osmosis image is built from does not have to be included in the image itself.
With the current design, since all codebase is copied over, a small tweak to any file causes the image to be rebuilt from scratch.
With the new design, we could copy only the items that we need. If a file that is not included in the image is changed (i.e. Dockerfile), it will not require the image to be rebuilt from the COPY directive:
COPY x/gov app Makefile /osmosis
Additionally, this change will help to reduce the image size and reduce the likelihood of security vulnerabilities since only the relevant files are included in the final image.
Background
Task 2.1 - Only COPY the desired components in Dockerfile
Currently, in most of our Dockerfiles, we copy the entire repository:
osmosis/tests/localosmosis/Dockerfile
Line 12 in d5cd033
While this might seem convenient, it increases development time by requiring the entire repository to be copied every time one makes a small change.
It requires all subsequent layers to be rebuilt as well, further increasing the waiting time.
This is particularly frustrating when making changes to Dockerfiles that build the image. For example, a Dockerfile that the Osmosis image is built from does not have to be included in the image itself.
With the current design, since all codebase is copied over, a small tweak to any file causes the image to be rebuilt from scratch.
With the new design, we could copy only the items that we need. If a file that is not included in the image is changed (i.e. Dockerfile), it will not require the image to be rebuilt from the COPY directive:
Additionally, this change will help to reduce the image size and reduce the likelihood of security vulnerabilities since only the relevant files are included in the final image.
Resources
Tip #2
: https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/Task 2.2 - Utilzie .dockerignore to exclude files commonly not needed in Osmosis containers
We should update
.dockerignore
excluding the files that are not needed. For example,.md
files should probably not be in the final images.Status
The text was updated successfully, but these errors were encountered: