@@ -7,27 +7,35 @@ ENV CGO_ENABLED=0
77
88COPY server/go.mod ./
99COPY server/go.sum ./
10- RUN go mod download
10+ RUN --mount=type=cache,target=/root/.cache/go-build \
11+ --mount=type=cache,target=/go/pkg/mod \
12+ go mod download
1113
1214COPY server/ .
13- RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
15+ RUN --mount=type=cache,target=/root/.cache/go-build \
16+ --mount=type=cache,target=/go/pkg/mod \
17+ GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
1418 go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api
1519
1620# webrtc client
1721FROM node:22-bullseye-slim AS client
1822WORKDIR /src
1923COPY images/chromium-headful/client/package*.json ./
20- RUN npm install
24+ RUN --mount=type=cache,target=/root/.npm npm install
2125COPY images/chromium-headful/client/ .
22- RUN npm run build
26+ RUN --mount=type=cache,target=/root/.npm npm run build
2327
2428# xorg dependencies
2529FROM docker.io/ubuntu:22.04 AS xorg-deps
2630WORKDIR /xorg
2731ENV DEBIAN_FRONTEND=noninteractive
28- RUN set -eux; \
32+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=ubuntu2204-aptcache \
33+ --mount=type=cache,target=/var/lib/apt,sharing=locked,id=ubuntu2204-aptlib \
34+ rm -f /etc/apt/apt.conf.d/docker-clean; \
35+ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
36+ set -eux; \
2937 apt-get update; \
30- apt-get install -y \
38+ apt-get --no- install-recommends -y install \
3139 git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
3240 && rm -rf /var/lib/apt/lists/*;
3341COPY images/chromium-headful/xorg-deps/ /xorg/
@@ -54,9 +62,14 @@ FROM docker.io/ubuntu:22.04
5462ENV DEBIAN_FRONTEND=noninteractive
5563ENV DEBIAN_PRIORITY=high
5664
57- RUN apt-get update && \
65+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=ubuntu2204-aptcache \
66+ --mount=type=cache,target=/var/lib/apt,sharing=locked,id=ubuntu2204-aptlib \
67+ rm -f /etc/apt/apt.conf.d/docker-clean; \
68+ echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
69+ apt-get update && \
5870 apt-get -y upgrade && \
59- apt-get -y install \
71+ apt-get --no-install-recommends -y install \
72+ gpg-agent \
6073 # UI Requirements
6174 xvfb \
6275 xterm \
@@ -88,39 +101,44 @@ RUN apt-get update && \
88101 software-properties-common && \
89102 # Userland apps
90103 sudo add-apt-repository ppa:mozillateam/ppa && \
91- sudo apt-get install -y --no-install-recommends \
92- chromium-browser \
93- libreoffice \
104+ sudo apt-get --no-install-recommends -y install \
94105 x11-apps \
95- xpdf \
96- gedit \
97- xpaint \
98106 tint2 \
99- galculator \
100- pcmanfm \
101107 wget \
102108 xdg-utils \
103109 libvulkan1 \
104110 fonts-liberation \
105- unzip && \
106- apt-get clean
111+ unzip;
107112
108113# install ffmpeg manually since the version available in apt is from the 4.x branch due to #drama.
109114# as of writing these static builds will be the latest 7.0.x release.
110- RUN set -eux; \
115+ RUN --mount=type=cache,target=/tmp/cache/ffmpeg,id=ffmpeg \
116+ set -eux; \
111117 URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz" ; \
112- echo "Downloading FFmpeg static build from $URL" ; \
113- curl -fsSL "$URL" -o /tmp/ffmpeg.tar.xz; \
114- tar -xJf /tmp/ffmpeg.tar.xz -C /tmp; \
118+ echo "Downloading FFmpeg MD5 checksum" ; \
119+ curl -fsSL "${URL}.md5" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; \
120+ sed -i -e 's/ .*$/ \/ tmp\/ cache\/ ffmpeg\/ ffmpeg.tar.xz/' /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; \
121+ echo "Checking cache for FFmpeg archive and validating MD5 checksum" ; \
122+ if md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; then \
123+ echo "Checksum validated, using cached FFmpeg archive" ; \
124+ else \
125+ echo "Downloading FFmpeg static build from $URL" ; \
126+ curl -fsSL "$URL" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz; \
127+ echo "Validating MD5 checksum of FFmpeg static build download" ; \
128+ md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; \
129+ fi; \
130+ tar -xJf /tmp/cache/ffmpeg/ffmpeg.tar.xz -C /tmp; \
115131 install -m755 /tmp/ffmpeg-*/ffmpeg /usr/local/bin/ffmpeg; \
116132 install -m755 /tmp/ffmpeg-*/ffprobe /usr/local/bin/ffprobe; \
117133 rm -rf /tmp/ffmpeg*
118134
119135# runtime
120136ENV USERNAME=root
121- RUN set -eux; \
137+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=ubuntu2204-aptcache \
138+ --mount=type=cache,target=/var/lib/apt,sharing=locked,id=ubuntu2204-aptlib \
139+ set -eux; \
122140 apt-get update; \
123- apt-get install -y -- no-install-recommends \
141+ apt-get -- no-install-recommends -y install \
124142 wget ca-certificates python2 supervisor xclip xdotool \
125143 pulseaudio dbus-x11 xserver-xorg-video-dummy \
126144 libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 \
@@ -131,7 +149,7 @@ RUN set -eux; \
131149 # install libxcvt0 (not available in debian:bullseye)
132150 ARCH=$(dpkg --print-architecture); \
133151 wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_${ARCH}.deb; \
134- apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_${ARCH}.deb; \
152+ apt-get --no-install-recommends install ./libxcvt0_0.1.2-1_${ARCH}.deb; \
135153 rm ./libxcvt0_0.1.2-1_${ARCH}.deb; \
136154 #
137155 # workaround for an X11 problem: http://blog.tigerteufel.de/?p=476
@@ -146,14 +164,15 @@ RUN set -eux; \
146164 /home/$USERNAME/.local/share/xorg; \
147165 chmod 1777 /var/log/neko; \
148166 chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
149- chown -R $USERNAME:$USERNAME /home/$USERNAME; \
150- # clean up
151- apt-get clean -y; \
152- rm -rf /var/lib/apt/lists/* /var/cache/apt/
167+ chown -R $USERNAME:$USERNAME /home/$USERNAME;
153168
154169# install chromium and sqlite3 for debugging the cookies file
155- RUN add-apt-repository -y ppa:xtradeb/apps
156- RUN apt update -y && apt install -y chromium sqlite3
170+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=ubuntu2204-aptcache \
171+ --mount=type=cache,target=/var/lib/apt,sharing=locked,id=ubuntu2204-aptlib \
172+ add-apt-repository -y ppa:xtradeb/apps;
173+ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=ubuntu2204-aptcache \
174+ --mount=type=cache,target=/var/lib/apt,sharing=locked,id=ubuntu2204-aptlib \
175+ apt update -y && apt --no-install-recommends -y install chromium sqlite3;
157176
158177# setup desktop env & app
159178ENV DISPLAY_NUM=1
0 commit comments