Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 116 additions & 54 deletions images/chromium-headful/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,75 +1,166 @@
FROM docker.io/golang:1.25.0 AS server-builder
WORKDIR /workspace/server

ARG TARGETOS
# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-golang1250
ENV CGO_ENABLED=0

COPY server/go.mod ./
COPY server/go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
go mod download

COPY server/ .

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

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

# webrtc client
FROM node:22-bullseye-slim AS client
WORKDIR /src

# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-node22bullseye

COPY images/chromium-headful/client/package*.json ./
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm install
COPY images/chromium-headful/client/ .
RUN --mount=type=cache,target=/root/.npm npm run build
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm run build

# xorg dependencies
FROM docker.io/ubuntu:22.04 AS xorg-deps
WORKDIR /xorg

# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204

ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
set -eux; \
apt-get update; \
apt-get --no-install-recommends -y install \
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev;
COPY images/chromium-headful/xorg-deps/ /xorg/
# build xf86-video-dummy v0.3.8 with RandR support
RUN set -eux; \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
cd xf86-video-dummy/v0.3.8; \
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
autoreconf -v --install; \
./configure; \
make -j$(nproc); \
make install;
# build custom input driver
RUN set -eux; \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
make install;

FROM docker.io/ubuntu:22.04 AS ffmpeg-downloader
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM docker.io/ubuntu:22.04 AS ffmpeg-downloader
FROM docker.io/ubuntu:22.04 AS ffmpeg-downloader
ARG TARGETARCH

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context the failure I was seeing:

[kernel-images-api] panic: ffmpeg not found or not executable: signal: trace/breakpoint trap
[kernel-images-api]
[kernel-images-api] goroutine 1 [running]:
[kernel-images-api] main.mustFFmpeg()
[kernel-images-api] 	/workspace/server/cmd/api/main.go:212 +0x90
[kernel-images-api] main.main()
[kernel-images-api] 	/workspace/server/cmd/api/main.go:48 +0x2b8
[kernel-images-api] time=2025-11-03T11:27:53.645-08:00 level=INFO msg="server configuration" config="&{Port:10001 FrameRate:10 DisplayNum:1 MaxSizeInMB:500 OutputDir:/recordings PathToFFmpeg:ffmpeg LogCDPMessages:false}"
[kernel-images-api] panic: ffmpeg not found or not executable: signal: trace/breakpoint trap
[kernel-images-api]
[kernel-images-api] goroutine 1 [running]:
[kernel-images-api] main.mustFFmpeg()
[kernel-images-api] 	/workspace/server/cmd/api/main.go:212 +0x90
[kernel-images-api] main.main()
[kernel-images-api] 	/workspace/server/cmd/api/main.go:48 +0x2b8
kernel-images-api: ERROR (spawn error)

under the hood when running build-docker.sh on my macbook I ended up with the wrong arch

root@5c30d0e00714:/# which ffmpeg
/usr/local/bin/ffmpeg
root@5c30d0e00714:/# ls -la /usr/local/bin/ffmpeg
-rwxr-xr-x 1 root root 137227080 Nov  3 19:23 /usr/local/bin/ffmpeg
root@5c30d0e00714:/# /usr/local/bin/ffmpeg -version
rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
 Trace/breakpoint trap
root@5c30d0e00714:/# ldd /usr/local/bin/ffmpeg
	not a dynamic executable
root@5c30d0e00714:/# uname -m
aarch64
root@5c30d0e00714:/# dpkg --print-architecture
arm64


# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204

RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -xe; \
rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
apt-get -yqq update; \
apt-get -yqq --no-install-recommends install ca-certificates curl xz-utils;

# Download FFmpeg (latest static build) for the recording server
RUN --mount=type=cache,target=/tmp/cache/ffmpeg,sharing=locked,id=$CACHEIDPREFIX-ffmpeg \
<<-'EOT'
set -eux
FFMPEG_CACHE_PATH="/tmp/cache/ffmpeg"
case ${TARGETARCH:-amd64} in
"amd64") FFMPEG_TARGET_ARCH="64" ;;
"arm64") FFMPEG_TARGET_ARCH="arm64" ;;
esac
FFMPEG_TARGET=linux${FFMPEG_TARGET_ARCH:?}
ARCHIVE_NAME="ffmpeg-n7.1-latest-${FFMPEG_TARGET}-gpl-7.1.tar.xz"
FFMPEG_CACHED_ARCHIVE_PATH="$FFMPEG_CACHE_PATH/$ARCHIVE_NAME"
FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH="$FFMPEG_CACHED_ARCHIVE_PATH.sha256"
URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/$ARCHIVE_NAME"
TEMPORARY_SHA256_CHECKSUM_PATH=$(mktemp /tmp/tmp_sha256.XXXXXXXXXX)
CONTINUE="true"
echo "Downloading FFmpeg checksum"
if curl --connect-timeout 10 -fsSL "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/checksums.sha256" -o $TEMPORARY_SHA256_CHECKSUM_PATH; then
grep -F "$ARCHIVE_NAME" $TEMPORARY_SHA256_CHECKSUM_PATH > $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH
else
echo "Failed to connect to ffmpeg static build provider for checksum."
echo "Checking for cached version to use."
if [ -f "$FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH" ]; then
echo "Found cached checksum."
else
echo "Unable to locate cached checksum."
CONTINUE="false"
fi
fi
rm $TEMPORARY_SHA256_CHECKSUM_PATH

if [ "$CONTINUE" = "false" ]; then
exit 1
fi

echo "Checking cache for FFmpeg archive and validating checksum"
if (cd $FFMPEG_CACHE_PATH && sha256sum --check $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH); then
echo "Checksum validated, using cached FFmpeg archive"
else
echo "Downloading FFmpeg static build from $URL"
curl -fsSL "$URL" -o $FFMPEG_CACHED_ARCHIVE_PATH
echo "Validating checksum of FFmpeg static build download"
(cd $FFMPEG_CACHE_PATH && sha256sum --check $FFMPEG_CACHED_ARCHIVE_CHECKSUM_PATH)
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: FFmpeg Build Failures Due to Checksum Validation Issues

The FFmpeg download and caching logic has a couple of issues that can cause builds to fail. If the remote checksum download fails, a newly fetched 'latest' archive is incorrectly validated against an outdated cached checksum. Separately, if the archive name isn't found in the checksum file, the file can be corrupted, preventing successful validation.

Additional Locations (1)

Fix in Cursor Fix in Web


tar -xJf $FFMPEG_CACHED_ARCHIVE_PATH -C /tmp
install -m755 /tmp/ffmpeg-*/bin/ffmpeg /usr/local/bin/ffmpeg
install -m755 /tmp/ffmpeg-*/bin/ffprobe /usr/local/bin/ffprobe
rm -rf /tmp/ffmpeg*
EOT

FROM ghcr.io/onkernel/neko/base:3.0.8-v1.3.0 AS neko
# ^--- now has event.SYSTEM_PONG with legacy support to keepalive
FROM node:22-bullseye-slim AS node-22
FROM docker.io/ubuntu:22.04

# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204

ENV DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_PRIORITY=high

RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache; \
apt-get update && \
Expand Down Expand Up @@ -119,45 +210,16 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptca
fonts-nanum \
fontconfig \
unzip && \
apt-get clean && fc-cache -f
fc-cache -f

# install ffmpeg manually since the version available in apt is from the 4.x branch due to #drama.
# as of writing these static builds will be the latest 7.0.x release.
RUN --mount=type=cache,target=/tmp/cache/ffmpeg,id=ffmpeg \
<<-'EOT'
set -eux
URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"
echo "Downloading FFmpeg MD5 checksum"
if ! curl --connect-timeout 10 -fsSL "${URL}.md5" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; then
echo "Failed to connect to ffmpeg static build provider for MD5 checksum."
echo "Checking for cached version to use."
if [ ! -f /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5 ]; then
echo "Unable to locate cached MD5 checksum. Exiting."
exit 1
else
echo "Found cached MD5 checksum."
fi
fi
sed -i -e 's/ .*$/ \/tmp\/cache\/ffmpeg\/ffmpeg.tar.xz/' /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5
echo "Checking cache for FFmpeg archive and validating MD5 checksum"
if md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5; then
echo "Checksum validated, using cached FFmpeg archive"
else
echo "Downloading FFmpeg static build from $URL"
curl -fsSL "$URL" -o /tmp/cache/ffmpeg/ffmpeg.tar.xz
echo "Validating MD5 checksum of FFmpeg static build download"
md5sum --check /tmp/cache/ffmpeg/ffmpeg.tar.xz.md5
fi
tar -xJf /tmp/cache/ffmpeg/ffmpeg.tar.xz -C /tmp
install -m755 /tmp/ffmpeg-*/ffmpeg /usr/local/bin/ffmpeg
install -m755 /tmp/ffmpeg-*/ffprobe /usr/local/bin/ffprobe
rm -rf /tmp/ffmpeg*
EOT
COPY --from=ffmpeg-downloader /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=ffmpeg-downloader /usr/local/bin/ffprobe /usr/local/bin/ffprobe

# runtime
ENV USERNAME=root
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
apt-get update; \
apt-get --no-install-recommends -y install \
Expand Down Expand Up @@ -190,11 +252,11 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptca
chown -R $USERNAME:$USERNAME /home/$USERNAME;

# install chromium and sqlite3 for debugging the cookies file
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
add-apt-repository -y ppa:xtradeb/apps;
RUN --mount=type=cache,target=/var/cache/apt,sharing=private,id=ubuntu2204-aptcache \
--mount=type=cache,target=/var/lib/apt,sharing=private,id=ubuntu2204-aptlib \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
apt update -y && \
apt -y install chromium && \
apt --no-install-recommends -y install sqlite3;
Expand All @@ -215,7 +277,7 @@ RUN set -eux; \
fi

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

# setup desktop env & app
ENV DISPLAY_NUM=1
Expand Down
9 changes: 7 additions & 2 deletions images/chromium-headful/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ FROM $BASE_IMAGE AS client

WORKDIR /src

# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-node18bullseye

#
# install dependencies
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm install
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm install

#
# build client
COPY . .
RUN --mount=type=cache,target=/root/.npm npm run build
RUN --mount=type=cache,target=/root/.npm,id=$CACHEIDPREFIX-npm npm run build

#
# artifacts from this stage
Expand Down
18 changes: 13 additions & 5 deletions images/chromium-headful/xorg-deps/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ FROM $BASE_IMAGE AS xorg-deps

WORKDIR /xorg

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

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

# build custom input driver
RUN set -eux; \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
cd xf86-input-neko; \
./autogen.sh --prefix=/usr; \
./configure; \
Expand Down
14 changes: 10 additions & 4 deletions images/chromium-headful/xorg-deps/xf86-input-neko/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM debian:bullseye-slim

ENV DEBIAN_FRONTEND=noninteractive
# Allow cross-compilation when building with BuildKit platforms
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-debianbullseye

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

COPY ./ /app/

RUN set -eux; \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
set -eux; \
./autogen.sh --prefix=/usr; \
./configure; \
make -j$(nproc); \
Expand Down
Loading
Loading