Skip to content

Commit 1f45a25

Browse files
greatgitsbyclaude
andauthored
build: unify kernel + system Docker builder (#27)
* unify * add missing deps * add findutils to alpine builder for GNU find -printf support Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * perl --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3721814 commit 1f45a25

File tree

4 files changed

+42
-47
lines changed

4 files changed

+42
-47
lines changed

tools/build/Dockerfile.builder

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
1-
FROM ghcr.io/void-linux/void-glibc-full
1+
# check=error=true
22

3-
RUN xbps-install -yS
3+
FROM alpine:3.23.3
44

5-
RUN xbps-install -y \
6-
base-devel \
5+
ARG UNAME
6+
ARG UID
7+
ARG GID
8+
9+
RUN apk add --no-cache \
10+
android-tools \
711
bash \
12+
bc \
13+
bison \
14+
build-base \
815
ccache \
16+
e2fsprogs \
17+
findutils \
18+
flex \
919
git \
10-
openssl-devel \
11-
python3 && \
12-
if [ "$(uname -m)" != "aarch64" ]; then xbps-install -y cross-aarch64-linux-gnu; fi && \
13-
xbps-remove -O
20+
libcap \
21+
linux-headers \
22+
openssl \
23+
openssl-dev \
24+
perl \
25+
python3
26+
27+
# Cross-compiler for x86_64 hosts building aarch64 kernel
28+
# gcc-aarch64-none-elf is bare-metal but works for kernel (freestanding code)
29+
RUN if [ "$(uname -m)" != "aarch64" ]; then \
30+
apk add --no-cache gcc-aarch64-none-elf binutils-aarch64-none-elf; \
31+
fi
32+
33+
RUN if [ ${UID:-0} -ne 0 ] && [ ${GID:-0} -ne 0 ]; then \
34+
deluser $(getent passwd ${UID} | cut -d : -f 1) > /dev/null 2>&1; \
35+
delgroup $(getent group ${GID} | cut -d : -f 1) > /dev/null 2>&1; \
36+
addgroup -g ${GID} ${UNAME} && \
37+
adduser -u ${UID} -G ${UNAME} -D ${UNAME} \
38+
;fi
1439

1540
ENTRYPOINT ["tail", "-f", "/dev/null"]

tools/build/Dockerfile.system-builder

Lines changed: 0 additions & 33 deletions
This file was deleted.

tools/build/build_kernel.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ fi
2222
# Build docker container
2323
echo "Building vamos-builder docker image"
2424
export DOCKER_BUILDKIT=1
25-
docker build -f tools/build/Dockerfile.builder -t vamos-builder "$DIR"
25+
docker build -f tools/build/Dockerfile.builder -t vamos-builder "$DIR" \
26+
--build-arg UNAME="$(id -nu)" \
27+
--build-arg UID="$(id -u)" \
28+
--build-arg GID="$(id -g)"
2629

2730
echo "Starting vamos-builder container"
2831
CONTAINER_ID=$(docker run -d -u "$(id -u):$(id -g)" -v "$DIR":"$DIR" -w "$DIR" vamos-builder)
@@ -54,7 +57,7 @@ build_kernel() {
5457
ARCH_HOST=$(uname -m)
5558
export ARCH=arm64
5659
if [ "$ARCH_HOST" != "aarch64" ] && [ "$ARCH_HOST" != "arm64" ]; then
57-
export CROSS_COMPILE=aarch64-linux-gnu-
60+
export CROSS_COMPILE=aarch64-none-elf-
5861
fi
5962

6063
# ccache

tools/build/build_system.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ export DOCKER_BUILDKIT=1
4949
docker buildx build -f tools/build/Dockerfile --check "$DIR"
5050

5151
# Setup mount container for macOS and CI support
52-
echo "Building system-builder docker image"
53-
docker build -f tools/build/Dockerfile.system-builder -t vamos-system-builder "$DIR" \
52+
echo "Building vamos-builder docker image"
53+
docker build -f tools/build/Dockerfile.builder -t vamos-builder "$DIR" \
5454
--build-arg UNAME="$(id -nu)" \
5555
--build-arg UID="$(id -u)" \
5656
--build-arg GID="$(id -g)"
5757

58-
echo "Starting system-builder container"
59-
MOUNT_CONTAINER_ID=$(docker run -d --privileged -v "$DIR:$DIR" vamos-system-builder)
58+
echo "Starting builder container"
59+
MOUNT_CONTAINER_ID=$(docker run -d --privileged -v "$DIR:$DIR" vamos-builder)
6060

6161
# Cleanup containers on possible exit
6262
trap "echo \"Cleaning up containers:\"; \

0 commit comments

Comments
 (0)