Skip to content

Commit 74816a4

Browse files
committed
feat: try out docker buildx caching for APT
1 parent 52c949a commit 74816a4

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/docker/Dockerfile.ubuntu-build

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ COPY . ./
77

88
# install build dependencies
99
# taken from https://github.com/dragonflydb/dragonfly/blob/main/.github/workflows/release.yml#L60-L65
10-
RUN export DEBIAN_FRONTEND=noninteractive && \
10+
RUN \
11+
rm -f /etc/apt/apt.conf.d/docker-clean; \
12+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
13+
14+
RUN \
15+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
16+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
17+
export DEBIAN_FRONTEND=noninteractive && \
1118
apt update && \
1219
apt install -q -y autoconf-archive cmake curl git libssl-dev \
1320
libunwind-dev ninja-build libtool gcc-9 g++-9 libboost-fiber-dev \
@@ -28,11 +35,12 @@ RUN curl -O https://raw.githubusercontent.com/ncopa/su-exec/212b75144bbc06722fbd
2835
# Now prod image
2936
FROM ubuntu:20.04
3037

31-
# ARG in fact change the env vars during the build process
32-
# ENV persist the env vars for the built image as well.
33-
ARG DEBIAN_FRONTEND=noninteractive
34-
35-
RUN apt clean && apt update && apt -y install netcat-openbsd
38+
RUN \
39+
--mount=type=tmpfs,target=/var/cache/apt \
40+
--mount=type=tmpfs,target=/var/lib/apt \
41+
export DEBIAN_FRONTEND=noninteractive && \
42+
apt update && \
43+
apt install -q -y netcat-openbsd
3644

3745
RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly
3846
RUN mkdir /data && chown dfly:dfly /data

0 commit comments

Comments
 (0)