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
Optimize Dockerfile for improved cleanup and smaller image size
This commit optimizes the Dockerfile to enhance the cleanup process and
reduce the resulting image size. The changes are as follows:
1. Consolidated the `wget`, `dpkg`, and removal of the downloaded .deb
file and apt `/var/lib/apt/lists/*` into a single `RUN` command. This
effectively reduces the image size as the cleanup occurs in the same
Docker layer. This approach replaces the unnecessary `apt-get clean`
that is automatically performed in Debian/Ubuntu base images.
2. Use `--no-install-recommends` flag with `apt-get install` to prevent
unnecessary packages from being installed.
3. Apply `--no-cache-dir` flag when using `pip install` to prevent
caching and reduce image size.
These changes result in a more efficient Docker build process and a
smaller, cleaner final Docker image. Specifically, the image size was
reduced from 977MB to 949MB, as you can see below.
```
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
smallweb after 7206ce8c6966 12 minutes ago 949MB
smallweb before c92947befbe9 12 minutes ago 977MB
```
0 commit comments