Skip to content

Commit ce46982

Browse files
Update ffmpeg and change static build provider (#64)
Please merge PR #60 prior to merging this PR. The basis of this PR is PR #60 and once merged this diff should clear up. This PR changes the provider for static ffmpeg builds to a Github repository source linked from [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html). The associated checksum work is updated as necessitated by the change from MD5 to SHA256. The build for ffmpeg is set to the latest version and will continually update as new versions are released. Updating without some form of pinning may or may not be an acceptable approach here. The old provider could be added as a backup. Issues could arise in cases where the fallback is used as builds between providers may not be versioned 1:1 (not in a strict reproducibility sense). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces FFmpeg static builds with BtbN GitHub releases using SHA256 verification and adds platform-scoped BuildKit caches across Dockerfiles for faster, reproducible builds. > > - **FFmpeg**: > - Add dedicated `ffmpeg-downloader` stage (Ubuntu 22.04) that fetches from `BtbN/FFmpeg-Builds` with SHA256 verification and arch selection; copy `ffmpeg`/`ffprobe` into final images. > - Remove old inline downloads and MD5 checks in `images/chromium-headful/Dockerfile` and `images/chromium-headless/image/Dockerfile`. > - **Build performance (BuildKit caching)**: > - Introduce platform-aware cache prefix `CACHEIDPREFIX` using `TARGETOS`/`TARGETARCH`. > - Add cache mounts for `apt`, `npm`, and `go` in `chromium-headful`, `chromium-headless`, `client`, `xorg-deps`, and `xf86-input-neko` Dockerfiles. > - **Misc Dockerfile tweaks**: > - Standardize `ARG TARGETOS/TARGETARCH` across stages; keep downloaded APT packages and use locked cache sharing; minor cleanup (e.g., switch global npm installs to cached). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2f19ef4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --- <!-- mesa-description-start --> ## TL;DR Switched the static `ffmpeg` build provider to a more reliable, official source and significantly optimized Docker image builds across the project by leveraging BuildKit caching. ## Why we made these changes The previous `ffmpeg` provider was unreliable, causing potential build failures. The new provider is linked directly from the official `ffmpeg.org` website, ensuring a trusted and up-to-date source. Additionally, our Docker builds were inefficient; implementing widespread BuildKit caching dramatically speeds up build times and reduces final image sizes by avoiding redundant package downloads. ## What changed? - **FFmpeg Provider:** - Changed the download source for static `ffmpeg` builds to the `BtbN/FFmpeg-Builds` GitHub repository. - Updated the checksum verification from MD5 to SHA256 to match the new provider. - Pinned the build to the `latest` release for continuous updates. - **Build Performance & Image Size:** - Optimized all major Dockerfiles (`chromium-headful`, `chromium-headless`, `xorg-deps`, etc.) to use BuildKit cache mounts for `apt`, `npm`, and `go` package management. - Consistently used `--no-install-recommends` during `apt-get install` across all relevant Dockerfiles to create leaner final images. - **Configuration:** - Added `.mise.toml` to the project's `.gitignore` to ignore local `mise` tool version configurations. ## Validation - [ ] Verify that all Docker images build successfully. - [ ] Confirm that `ffmpeg` is correctly installed and functional inside the final images. - [ ] Check that subsequent builds are noticeably faster due to the new caching mechanisms. <sup>_Description generated by Mesa. [Update settings](https://app.mesa.dev/onkernel/settings/pull-requests)_</sup> <!-- mesa-description-end --> --------- Co-authored-by: Matt Marangoni <[email protected]>
1 parent b51da91 commit ce46982

File tree

5 files changed

+239
-111
lines changed

5 files changed

+239
-111
lines changed

images/chromium-headful/Dockerfile

Lines changed: 116 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,166 @@
11
FROM docker.io/golang:1.25.0 AS server-builder
22
WORKDIR /workspace/server
33

4-
ARG TARGETOS
4+
# Allow cross-compilation when building with BuildKit platforms
55
ARG TARGETARCH
6+
ARG TARGETOS
7+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-golang1250
68
ENV CGO_ENABLED=0
79

810
COPY server/go.mod ./
911
COPY server/go.sum ./
10-
RUN --mount=type=cache,target=/root/.cache/go-build \
11-
--mount=type=cache,target=/go/pkg/mod \
12+
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
13+
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
1214
go mod download
1315

1416
COPY server/ .
1517

1618
# Build kernel-images API
17-
RUN --mount=type=cache,target=/root/.cache/go-build \
18-
--mount=type=cache,target=/go/pkg/mod \
19+
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
20+
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
1921
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
2022
go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api
2123

2224
# Build chromium launcher
23-
RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
25+
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
26+
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
27+
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
2428
go build -ldflags="-s -w" -o /out/chromium-launcher ./cmd/chromium-launcher
2529

2630
# webrtc client
2731
FROM node:22-bullseye-slim AS client
2832
WORKDIR /src
33+
34+
# Allow cross-compilation when building with BuildKit platforms
35+
ARG TARGETARCH
36+
ARG TARGETOS
37+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-node22bullseye
38+
2939
COPY images/chromium-headful/client/package*.json ./
30-
RUN --mount=type=cache,target=/root/.npm npm install
40+
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm install
3141
COPY images/chromium-headful/client/ .
32-
RUN --mount=type=cache,target=/root/.npm npm run build
42+
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm run build
3343

3444
# xorg dependencies
3545
FROM docker.io/ubuntu:22.04 AS xorg-deps
3646
WORKDIR /xorg
47+
48+
# Allow cross-compilation when building with BuildKit platforms
49+
ARG TARGETARCH
50+
ARG TARGETOS
51+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
52+
3753
ENV DEBIAN_FRONTEND=noninteractive
38-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
39-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
54+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
55+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
56+
set -eux; \
4057
rm -f /etc/apt/apt.conf.d/docker-clean; \
4158
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
42-
set -eux; \
4359
apt-get update; \
4460
apt-get --no-install-recommends -y install \
4561
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev;
4662
COPY images/chromium-headful/xorg-deps/ /xorg/
4763
# build xf86-video-dummy v0.3.8 with RandR support
48-
RUN set -eux; \
64+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
65+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
66+
set -eux; \
4967
cd xf86-video-dummy/v0.3.8; \
5068
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
5169
autoreconf -v --install; \
5270
./configure; \
5371
make -j$(nproc); \
5472
make install;
5573
# build custom input driver
56-
RUN set -eux; \
74+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
75+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
76+
set -eux; \
5777
cd xf86-input-neko; \
5878
./autogen.sh --prefix=/usr; \
5979
./configure; \
6080
make -j$(nproc); \
6181
make install;
6282

83+
FROM docker.io/ubuntu:22.04 AS ffmpeg-downloader
84+
85+
# Allow cross-compilation when building with BuildKit platforms
86+
ARG TARGETARCH
87+
ARG TARGETOS
88+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
89+
90+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
91+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
92+
set -xe; \
93+
rm -f /etc/apt/apt.conf.d/docker-clean; \
94+
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
95+
apt-get -yqq update; \
96+
apt-get -yqq --no-install-recommends install ca-certificates curl xz-utils;
97+
98+
# Download FFmpeg (latest static build) for the recording server
99+
RUN --mount=type=cache,target=/tmp/cache/ffmpeg,sharing=locked,id=$CACHEIDPREFIX-ffmpeg \
100+
<<-'EOT'
101+
set -eux
102+
FFMPEG_CACHE_PATH="/tmp/cache/ffmpeg"
103+
case ${TARGETARCH:-amd64} in
104+
"amd64") FFMPEG_TARGET_ARCH="64" ;;
105+
"arm64") FFMPEG_TARGET_ARCH="arm64" ;;
106+
esac
107+
FFMPEG_TARGET=linux${FFMPEG_TARGET_ARCH:?}
108+
ARCHIVE_NAME="ffmpeg-n7.1-latest-${FFMPEG_TARGET}-gpl-7.1.tar.xz"
109+
FFMPEG_CACHED_ARCHIVE_PATH="$FFMPEG_CACHE_PATH/$ARCHIVE_NAME"
110+
FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH="$FFMPEG_CACHED_ARCHIVE_PATH.sha256"
111+
URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/$ARCHIVE_NAME"
112+
TEMPORARY_SHA256_CHECKSUM_PATH=$(mktemp /tmp/tmp_sha256.XXXXXXXXXX)
113+
CONTINUE="true"
114+
echo "Downloading FFmpeg checksum"
115+
if curl --connect-timeout 10 -fsSL "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/checksums.sha256" -o $TEMPORARY_SHA256_CHECKSUM_PATH; then
116+
grep -F "$ARCHIVE_NAME" $TEMPORARY_SHA256_CHECKSUM_PATH > $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH
117+
else
118+
echo "Failed to connect to ffmpeg static build provider for checksum."
119+
echo "Checking for cached version to use."
120+
if [ -f "$FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH" ]; then
121+
echo "Found cached checksum."
122+
else
123+
echo "Unable to locate cached checksum."
124+
CONTINUE="false"
125+
fi
126+
fi
127+
rm $TEMPORARY_SHA256_CHECKSUM_PATH
128+
129+
if [ "$CONTINUE" = "false" ]; then
130+
exit 1
131+
fi
132+
133+
echo "Checking cache for FFmpeg archive and validating checksum"
134+
if (cd $FFMPEG_CACHE_PATH && sha256sum --check $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH); then
135+
echo "Checksum validated, using cached FFmpeg archive"
136+
else
137+
echo "Downloading FFmpeg static build from $URL"
138+
curl -fsSL "$URL" -o $FFMPEG_CACHED_ARCHIVE_PATH
139+
echo "Validating checksum of FFmpeg static build download"
140+
(cd $FFMPEG_CACHE_PATH && sha256sum --check $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH)
141+
fi
142+
143+
tar -xJf $FFMPEG_CACHED_ARCHIVE_PATH -C /tmp
144+
install -m755 /tmp/ffmpeg-*/bin/ffmpeg /usr/local/bin/ffmpeg
145+
install -m755 /tmp/ffmpeg-*/bin/ffprobe /usr/local/bin/ffprobe
146+
rm -rf /tmp/ffmpeg*
147+
EOT
148+
63149
FROM ghcr.io/onkernel/neko/base:3.0.8-v1.3.0 AS neko
64150
# ^--- now has event.SYSTEM_PONG with legacy support to keepalive
65151
FROM node:22-bullseye-slim AS node-22
66152
FROM docker.io/ubuntu:22.04
67153

154+
# Allow cross-compilation when building with BuildKit platforms
155+
ARG TARGETARCH
156+
ARG TARGETOS
157+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
158+
68159
ENV DEBIAN_FRONTEND=noninteractive
69160
ENV DEBIAN_PRIORITY=high
70161

71-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
72-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
162+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
163+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
73164
rm -f /etc/apt/apt.conf.d/docker-clean; \
74165
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
75166
apt-get update && \
@@ -119,45 +210,16 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptca
119210
fonts-nanum \
120211
fontconfig \
121212
unzip && \
122-
apt-get clean && fc-cache -f
213+
fc-cache -f
123214

124215
# install ffmpeg manually since the version available in apt is from the 4.x branch due to #drama.
125-
# as of writing these static builds will be the latest 7.0.x release.
126-
RUN --mount=type=cache,target=/tmp/cache/ffmpeg,id=ffmpeg \
127-
<<-'EOT'
128-
set -eux
129-
URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
130-
echo "Downloading FFmpeg MD5 checksum"
131-
if ! curl --connect-timeout 10 -fsSL "${URL}.md5" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; then
132-
echo "Failed to connect to ffmpeg static build provider for MD5 checksum."
133-
echo "Checking for cached version to use."
134-
if [ ! -f /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5 ]; then
135-
echo "Unable to locate cached MD5 checksum. Exiting."
136-
exit 1
137-
else
138-
echo "Found cached MD5 checksum."
139-
fi
140-
fi
141-
sed -i -e 's/ .*$/ \/tmp\/cache\/ffmpeg\/ffmpeg.tar.xz/' /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5
142-
echo "Checking cache for FFmpeg archive and validating MD5 checksum"
143-
if md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; then
144-
echo "Checksum validated, using cached FFmpeg archive"
145-
else
146-
echo "Downloading FFmpeg static build from $URL"
147-
curl -fsSL "$URL" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz
148-
echo "Validating MD5 checksum of FFmpeg static build download"
149-
md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5
150-
fi
151-
tar -xJf /tmp/cache/ffmpeg/ffmpeg.tar.xz -C /tmp
152-
install -m755 /tmp/ffmpeg-*/ffmpeg /usr/local/bin/ffmpeg
153-
install -m755 /tmp/ffmpeg-*/ffprobe /usr/local/bin/ffprobe
154-
rm -rf /tmp/ffmpeg*
155-
EOT
216+
COPY --from=ffmpeg-downloader /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
217+
COPY --from=ffmpeg-downloader /usr/local/bin/ffprobe /usr/local/bin/ffprobe
156218

157219
# runtime
158220
ENV USERNAME=root
159-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
160-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
221+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
222+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
161223
set -eux; \
162224
apt-get update; \
163225
apt-get --no-install-recommends -y install \
@@ -190,11 +252,11 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptca
190252
chown -R $USERNAME:$USERNAME /home/$USERNAME;
191253

192254
# install chromium and sqlite3 for debugging the cookies file
193-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
194-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
255+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
256+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
195257
add-apt-repository -y ppa:xtradeb/apps;
196-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
197-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
258+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
259+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
198260
apt update -y && \
199261
apt -y install chromium && \
200262
apt --no-install-recommends -y install sqlite3;
@@ -215,7 +277,7 @@ RUN set -eux; \
215277
fi
216278

217279
# Install TypeScript and Playwright globally
218-
RUN --mount=type=cache,target=/root/.npm npm install -g typescript playwright-core tsx
280+
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm install -g typescript playwright-core tsx
219281

220282
# setup desktop env & app
221283
ENV DISPLAY_NUM=1

images/chromium-headful/client/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ FROM $BASE_IMAGE AS client
33

44
WORKDIR /src
55

6+
# Allow cross-compilation when building with BuildKit platforms
7+
ARG TARGETARCH
8+
ARG TARGETOS
9+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-node18bullseye
10+
611
#
712
# install dependencies
813
COPY package*.json ./
9-
RUN --mount=type=cache,target=/root/.npm npm install
14+
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm install
1015

1116
#
1217
# build client
1318
COPY . .
14-
RUN --mount=type=cache,target=/root/.npm npm run build
19+
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm run build
1520

1621
#
1722
# artifacts from this stage

images/chromium-headful/xorg-deps/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ FROM $BASE_IMAGE AS xorg-deps
33

44
WORKDIR /xorg
55

6+
# Allow cross-compilation when building with BuildKit platforms
7+
ARG TARGETARCH
8+
ARG TARGETOS
9+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
610
ENV DEBIAN_FRONTEND=noninteractive
7-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
8-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
11+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
12+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
13+
set -eux; \
914
rm -f /etc/apt/apt.conf.d/docker-clean; \
1015
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
11-
set -eux; \
1216
apt-get update; \
1317
apt-get --no-install-recommends -y install \
1418
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev;
@@ -17,7 +21,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptca
1721
COPY . /xorg/
1822

1923
# build xf86-video-dummy v0.3.8 with RandR support
20-
RUN set -eux; \
24+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
25+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
26+
set -eux; \
2127
cd xf86-video-dummy/v0.3.8; \
2228
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
2329
autoreconf -v --install; \
@@ -26,7 +32,9 @@ RUN set -eux; \
2632
make install;
2733

2834
# build custom input driver
29-
RUN set -eux; \
35+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
36+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
37+
set -eux; \
3038
cd xf86-input-neko; \
3139
./autogen.sh --prefix=/usr; \
3240
./configure; \

images/chromium-headful/xorg-deps/xf86-input-neko/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
FROM debian:bullseye-slim
22

33
ENV DEBIAN_FRONTEND=noninteractive
4+
# Allow cross-compilation when building with BuildKit platforms
5+
ARG TARGETARCH
6+
ARG TARGETOS
7+
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-debianbullseye
48

5-
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=debian-bullseye-aptcache \
6-
--mount=type=cache,target=/var/lib/apt,sharing=private,id=debian-bullseye-aptlib \
9+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
10+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
11+
set -eux; \
712
rm -f /etc/apt/apt.conf.d/docker-clean; \
813
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
9-
set -eux; \
1014
apt-get update; \
1115
apt-get install --no-install-recommends -y \
1216
gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev;
@@ -15,7 +19,9 @@ WORKDIR /app
1519

1620
COPY ./ /app/
1721

18-
RUN set -eux; \
22+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
23+
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
24+
set -eux; \
1925
./autogen.sh --prefix=/usr; \
2026
./configure; \
2127
make -j$(nproc); \

0 commit comments

Comments
 (0)