Unify AMD and ARM Docker images

+ Initial groundwork for AMD64 builds on ARM/Rosetta. Not currently
viable due to bugs in either Linux or Rosetta which results in a
Sveltekit build hanging indefinitely.
This commit is contained in:
Damien Elmes 2025-01-14 10:09:09 +11:00
parent 9c0911891d
commit 0653dae86c
6 changed files with 33 additions and 87 deletions

View file

@ -1,71 +0,0 @@
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND="noninteractive"
ENV PYTHONPATH=/usr/lib/python3/dist-packages
RUN useradd -d /state -m -u 998 user
RUN apt-get update && apt install --yes gnupg ca-certificates && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 32A37959C2FA5C3C99EFBC32A79206696452D198 \
&& echo "deb https://apt.buildkite.com/buildkite-agent stable main" > /etc/apt/sources.list.d/buildkite-agent.list \
&& apt-get update \
&& apt-get install --yes --no-install-recommends \
autoconf \
bash \
buildkite-agent \
ca-certificates \
curl \
findutils \
g++ \
gcc \
git \
grep \
libdbus-1-3 \
libegl1 \
libfontconfig1 \
libgl1 \
libgstreamer-gl1.0-0 \
libgstreamer-plugins-base1.0 \
libgstreamer1.0-0 \
libnss3 \
libpulse-mainloop-glib0 \
libpulse-mainloop-glib0 \
libssl-dev \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxi6 \
libxkbcommon-x11-0 \
libxkbcommon0 \
libxkbfile1 \
libxrandr2 \
libxrender1 \
libxtst6 \
make \
pkg-config \
portaudio19-dev \
python3-dev \
rsync \
# -- begin only required for arm64/debian11
ninja-build \
clang-format \
python-is-python3 \
python3-pyqt5.qtwebengine \
# -- end only required for arm64/debian11
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/buildkite-agent/hooks && chown -R user /etc/buildkite-agent
COPY buildkite.cfg /etc/buildkite-agent/buildkite-agent.cfg
COPY environment /etc/buildkite-agent/hooks/environment
RUN mkdir /state/rust && chown user /state/rust
USER user
ENV CARGO_HOME=/state/rust/cargo
ENV RUSTUP_HOME=/state/rust/rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain none
WORKDIR /code/buildkite
ENTRYPOINT ["/usr/bin/buildkite-agent", "start"]

View file

@ -0,0 +1,11 @@
#!/bin/bash
# builds an 'anki-[amd|arm]' image for the current platform
#
# for a cross-compile on recent Docker:
# docker buildx create --use
# docker run --privileged --rm tonistiigi/binfmt --install amd64
# docker buildx build --platform linux/amd64 --tag anki-amd64 . --load
. common.inc
DOCKER_BUILDKIT=1 docker build --tag anki-${platform} .

View file

@ -0,0 +1,9 @@
#!/bin/bash
set -e
if [[ "$(uname -m)" == "x86_64" ]]; then
platform="amd"
else
platform="arm"
fi

View file

@ -1,33 +1,29 @@
#!/bin/bash
# - use 'BUILD=1 ./run.sh' to build image & run.
# - use './run.sh' to run in the foreground
# - use './run.sh serve' to daemonize.
set -e
. common.inc
if [ "$1" = "serve" ]; then
extra_args="-d --restart always"
else
extra_args="-it"
fi
if [ $(uname -m) = "aarch64" ]; then
arch=arm64
else
arch=amd64
fi
name=anki-${platform}
if [ -n "$BUILD" ]; then
DOCKER_BUILDKIT=1 docker build -f Dockerfile.${arch} --tag linci .
fi
if docker container inspect linci > /dev/null 2>&1; then
docker stop linci || true
docker container rm linci
# Stop and remove the existing container if it exists.
# This doesn't delete the associated volume.
if docker container inspect $name > /dev/null 2>&1; then
docker stop $name || true
docker container rm $name
fi
docker run $extra_args \
--name linci \
-v ci-state:/state \
--name $name \
-v ${name}-state:/state \
-e BUILDKITE_AGENT_TOKEN \
-e BUILDKITE_AGENT_TAGS \
linci
$name

View file

@ -11,6 +11,7 @@ echo "--- Install n2"
./tools/install-n2
if [ $(uname -m) = "aarch64" ]; then
export PYTHONPATH=/usr/lib/python3/dist-packages
./ninja wheels:anki
else
./ninja bundle