@@ -26,14 +26,19 @@ ARG DEBIAN_TAG=bookworm-slim
26
26
FROM debian:${DEBIAN_TAG} as kas-base
27
27
28
28
ARG SOURCE_DATE_EPOCH
29
+ ARG CACHE_SHARING=locked
29
30
30
31
ARG DEBIAN_TAG=bookworm-slim
31
32
ENV DEBIAN_BASE_IMAGE_TAG=${DEBIAN_TAG}
32
33
33
34
ARG TARGETPLATFORM
34
35
ARG DEBIAN_FRONTEND=noninteractive
35
36
ENV LANG=en_US.utf8
36
- RUN if echo "${DEBIAN_TAG}" | grep -q "[0-9]" ; then \
37
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
38
+ --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
39
+ rm -f /etc/apt/apt.conf.d/docker-clean && \
40
+ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-packages.conf && \
41
+ if echo "${DEBIAN_TAG}" | grep -q "[0-9]" ; then \
37
42
sed -i -e '/^URIs:/d' -e 's|^# http://snapshot\. |URIs: http://snapshot-cloudflare.|' \
38
43
/etc/apt/sources.list.d/debian.sources; \
39
44
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/use-snapshot.conf; \
@@ -47,8 +52,7 @@ RUN if echo "${DEBIAN_TAG}" | grep -q "[0-9]"; then \
47
52
gosu lsb-release file vim less procps tree tar bzip2 zstd pigz lz4 unzip tmux libncurses-dev \
48
53
git-lfs mercurial iproute2 ssh-client telnet curl rsync gnupg awscli sudo \
49
54
socat bash-completion python3-shtab python3-git && \
50
- apt-get clean && \
51
- rm -rf /var/lib/apt/* /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
55
+ rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
52
56
rm -f /etc/gitconfig && \
53
57
git config --system filter.lfs.clean 'git-lfs clean -- %f' && \
54
58
git config --system filter.lfs.smudge 'git-lfs smudge -- %f' && \
@@ -92,12 +96,15 @@ ENTRYPOINT ["/container-entrypoint"]
92
96
FROM kas-base as kas-isar
93
97
94
98
ARG SOURCE_DATE_EPOCH
99
+ ARG CACHE_SHARING=locked
95
100
96
101
# The install package list are actually taking 1:1 from their documentation,
97
102
# so there some packages that can already installed by other downstream layers.
98
103
# This will not change any image sizes on all the layers in use.
99
104
ENV LC_ALL=en_US.UTF-8
100
- RUN apt-get update && \
105
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
106
+ --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
107
+ apt-get update && \
101
108
apt-get install -y -f --no-install-recommends \
102
109
binfmt-support bzip2 mmdebstrap arch-test apt-utils dosfstools \
103
110
dpkg-dev gettext-base git mtools parted python3 python3-distutils \
@@ -106,8 +113,7 @@ RUN apt-get update && \
106
113
umoci skopeo \
107
114
python3-botocore \
108
115
debootstrap && \
109
- apt-get clean && \
110
- rm -rf /var/lib/apt/* /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
116
+ rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
111
117
sbuild-adduser builder && \
112
118
sed -i 's|# kas-isar: ||g' /container-entrypoint
113
119
@@ -120,12 +126,15 @@ USER builder
120
126
FROM kas-base as kas
121
127
122
128
ARG SOURCE_DATE_EPOCH
129
+ ARG CACHE_SHARING=locked
123
130
124
131
# The install package list are actually taking 1:1 from their documentation
125
132
# (exception: pylint3 -> pylint), so there some packages that can already
126
133
# installed by other downstream layers. This will not change any image sizes
127
134
# on all the layers in use.
128
- RUN apt-get update && \
135
+ RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
136
+ --mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
137
+ apt-get update && \
129
138
apt-get install --no-install-recommends -y \
130
139
gawk wget git diffstat unzip texinfo \
131
140
gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
@@ -134,7 +143,6 @@ RUN apt-get update && \
134
143
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
135
144
apt-get install --no-install-recommends -y gcc-multilib g++-multilib; \
136
145
fi && \
137
- apt-get clean && \
138
- rm -rf /var/lib/apt/* /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache
146
+ rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache
139
147
140
148
USER builder
0 commit comments