Skip to content

Commit 6d23d88

Browse files
greatgitsbyclaude
andcommitted
build_system: stream build output directly into rootfs
Pipe buildx tar output directly into the mounted rootfs instead of loading into Docker image store and then exporting. Skips the slow "exporting layers" step and the intermediate container. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0354c3e commit 6d23d88

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

build_system.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ fi
4848
export DOCKER_BUILDKIT=1
4949
docker buildx build -f Dockerfile.agnos --check $DIR
5050

51-
# Start build and create container
52-
echo "Building agnos-builder docker image"
53-
BUILD="docker buildx build --load"
54-
if [ ! -z "$NS" ]; then
55-
BUILD="nsc build --load"
56-
fi
57-
$BUILD -f Dockerfile.agnos -t agnos-builder $DIR --build-arg UBUNTU_BASE_IMAGE=$UBUNTU_FILE --platform=linux/arm64
58-
echo "Creating agnos-builder container"
59-
CONTAINER_ID=$(docker container create --entrypoint /bin/bash agnos-builder:latest)
60-
6151
# Check agnos-meta-builder Dockerfile
6252
docker buildx build --load -f Dockerfile.builder --check $DIR \
6353
--build-arg UNAME=$(id -nu) \
@@ -75,7 +65,7 @@ MOUNT_CONTAINER_ID=$(docker run -d --privileged -v $DIR:$DIR agnos-meta-builder)
7565

7666
# Cleanup containers on possible exit
7767
trap "echo \"Cleaning up containers:\"; \
78-
docker container rm -f $CONTAINER_ID $MOUNT_CONTAINER_ID" EXIT
68+
docker container rm -f $MOUNT_CONTAINER_ID" EXIT
7969

8070
# Define functions for docker execution
8171
exec_as_user() {
@@ -99,12 +89,21 @@ exec_as_root mount $ROOTFS_IMAGE $ROOTFS_DIR
9989
# Also unmount filesystem (overwrite previous trap)
10090
trap "exec_as_root umount -l $ROOTFS_DIR &> /dev/null || true; \
10191
echo \"Cleaning up containers:\"; \
102-
docker container rm -f $CONTAINER_ID $MOUNT_CONTAINER_ID" EXIT
92+
docker container rm -f $MOUNT_CONTAINER_ID" EXIT
10393

104-
# Extract image
105-
echo "Extracting docker image"
106-
docker container export -o $BUILD_DIR/filesystem.tar $CONTAINER_ID
107-
exec_as_root tar -xf $BUILD_DIR/filesystem.tar -C $ROOTFS_DIR > /dev/null
94+
# Build and export filesystem directly as tar, pipe into mounted rootfs
95+
# This skips --load (slow "exporting layers" into Docker image store) and docker container export
96+
echo "Building and extracting agnos-builder docker image"
97+
BUILD="docker buildx build"
98+
if [ ! -z "$NS" ]; then
99+
BUILD="nsc build"
100+
fi
101+
$BUILD -f Dockerfile.agnos \
102+
--output "type=tar,dest=-" \
103+
--provenance=false \
104+
--build-arg UBUNTU_BASE_IMAGE=$UBUNTU_FILE \
105+
--platform=linux/arm64 \
106+
"$DIR" | docker exec -i $MOUNT_CONTAINER_ID tar -xf - -C $ROOTFS_DIR
108107

109108
# Avoid detecting as container
110109
echo "Removing .dockerenv file"

0 commit comments

Comments
 (0)