-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the number of layers by one by combining RUN lines
Uses the new HEREDOC syntax supported by the more recent dockerfile version.
- Loading branch information
1 parent
e957cb3
commit 588beb1
Showing
1 changed file
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,21 @@ LABEL org.opencontainers.image.authors="[email protected]" \ | |
org.opencontainers.image.vendor="OpenSAFELY" \ | ||
org.opencontainers.image.source="https://github.com/opensafely-core/base-docker" | ||
|
||
# Disable automatic cache cleaning, and make `apt install` preserve caches. | ||
# This implies we should always use RUN --mount=cache on apt installs | ||
# Taken from docs: https://docs.docker.com/reference/dockerfile/#example-cache-apt-packages | ||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
|
||
# useful utility for installing apt packages in the most space efficient way | ||
# possible. It's worth it because this is the base image, and so any bloat | ||
# here affects all our images. Plus, it's then available for downstream images | ||
# to use. | ||
COPY docker-apt-install.sh /root/docker-apt-install.sh | ||
|
||
# install some base tools we want in all images | ||
# caching from docs: https://docs.docker.com/reference/dockerfile/#example-cache-apt-packages | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
UPGRADE=yes /root/docker-apt-install.sh ca-certificates sysstat lsof net-tools tcpdump vim strace file | ||
# Ccaching from docs: https://docs.docker.com/reference/dockerfile/#example-cache-apt-packages | ||
# Enable full caching of apt packages and metadata, undoing the debian defaults. | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked <<EOF | ||
rm -f /etc/apt/apt.conf.d/docker-clean | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
UPGRADE=yes /root/docker-apt-install.sh ca-certificates sysstat lsof net-tools tcpdump vim strace file | ||
EOF | ||
|
||
|
||
# record build info so downstream images know about the base image they were | ||
# built from | ||
|