Files
zosbuilder/build/docker-compose.yml
Jan De Landtsheer 709c4a0865 feat: implement rootless Docker with container management support
Docker Infrastructure:
- Added proper user namespace mapping in Dockerfile.alpine
- Created 'builder' user with host UID/GID mapping at build time
- Removed runtime user mapping (now handled in Dockerfile)
- Set up Rust environment for mapped user instead of root
- Fixed config mount consistency (removed :ro flags for real-time sync)

Container Management:
- Added 15 essential cgroup modules to modules-essential.list
- Complete cgroups v1 and v2 support for container orchestration
- Process control: cgroup_pids, cgroup_freezer, cgroup_cpuset
- Memory management: memcg, hugetlb_cgroup
- Network control: net_cls_cgroup, net_prio_cgroup
- Device access: cgroup_device, devices_cgroup
- Advanced features: cgroup_bpf, cgroup_perf_event, cgroup_debug

Environment Updates:
- Updated RFS Dockerfile to Alpine 3.22 for consistency
- Ensured proper /build directory permissions for mapped user

This enables true rootless operation with full container management
capabilities, fixing permission issues and enabling Zero-OS container
orchestration with complete resource control.
2025-08-25 09:44:47 +02:00

142 lines
4.4 KiB
YAML

services:
# Cached builder using multi-stage Dockerfile
builder:
build:
context: ..
dockerfile: build/Dockerfile.cached
target: final-builder
args:
BUILDMODE: "${BUILDMODE:-debug}"
TARGETARCH: "${TARGETARCH:-amd64}"
MINIMAL_MODE: "${MINIMAL_MODE:-false}"
USER_UID: "${USER_UID:-1000}"
USER_GID: "${USER_GID:-1000}"
USERNAME: "builder"
image: zero-os-alpine-builder:cached-${BUILDMODE:-debug}
container_name: zero-os-alpine-builder-cached
privileged: true
volumes:
# Mount source configs and scripts (configs writable for dev, scripts read-only for cache)
- ../configs:/build/configs
- ../scripts:/build/scripts:ro
# Mount Zero-OS components (writable for cargo build)
- ../components:/build/components
# Mount output directory
- ../output:/build/output
# Persistent cache directories for maximum caching
- build-cache:/build/cache
- source-cache:/build/source
- kernel-cache:/build/kernel
# Mount existing zinit config from main project
- ../configs/zinit:/mnt/zinit:ro
environment:
- BUILDMODE=${BUILDMODE:-debug}
- TARGETARCH=${TARGETARCH:-amd64}
- MINIMAL_MODE=${MINIMAL_MODE:-false}
working_dir: /build
command: ["/build/scripts/build-smart.sh"]
# Legacy builder for comparison/fallback
builder-legacy:
build:
context: ..
dockerfile: build/Dockerfile.alpine
args:
BUILDMODE: "${BUILDMODE:-debug}"
TARGETARCH: "${TARGETARCH:-amd64}"
MINIMAL_MODE: "${MINIMAL_MODE:-false}"
USER_UID: "${USER_UID:-1000}"
USER_GID: "${USER_GID:-1000}"
USERNAME: "builder"
image: zero-os-alpine-builder:legacy
container_name: zero-os-alpine-builder-legacy
privileged: true
volumes:
- ../configs:/build/configs
- ../scripts:/build/scripts:ro
- ../components:/build/components
- ../output:/build/output
- github-cache:/build/github
- kernel-cache-legacy:/build/kernel
- ../configs/zinit:/mnt/zinit:ro
environment:
- BUILDMODE=${BUILDMODE:-debug}
- TARGETARCH=${TARGETARCH:-amd64}
- MINIMAL_MODE=${MINIMAL_MODE:-false}
working_dir: /build
command: ["/build/scripts/build-initramfs.sh"]
# Quick shell access for debugging (uses cached builder)
shell:
extends: builder
container_name: zero-os-alpine-shell
command: /bin/sh
stdin_open: true
tty: true
# Development shell with full caches
dev-shell:
extends: builder
container_name: zero-os-alpine-dev-shell
command: /bin/sh -l
stdin_open: true
tty: true
environment:
- PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- CARGO_TARGET_DIR=/build/target-cache
volumes:
- ../configs:/build/configs
- ../scripts:/build/scripts
- ../components:/build/components
- ../output:/build/output
- build-cache:/build/cache
- source-cache:/build/source
- kernel-cache:/build/kernel
- target-cache:/build/target-cache
- ../configs/zinit:/mnt/zinit:ro
# Test build with minimal caching (for testing clean builds)
test:
extends: builder
container_name: zero-os-alpine-test
volumes:
- ../configs:/build/configs
- ../scripts:/build/scripts:ro
- ../components:/build/components
- ../output:/build/output
- ../configs/zinit:/mnt/zinit:ro
environment:
- BUILDMODE=debug
- TARGETARCH=amd64
- MINIMAL_MODE=${MINIMAL_MODE:-false}
# Cache management service
cache-info:
extends: builder
container_name: zero-os-alpine-cache-info
command: |
sh -c "
echo 'Build Cache Information:'
echo 'Cache directory: /build/cache'
ls -la /build/cache/ 2>/dev/null || echo 'No cache markers found'
echo ''
echo 'Source cache: /build/source'
ls -la /build/source/ 2>/dev/null || echo 'No source cache found'
echo ''
echo 'Kernel cache: /build/kernel'
ls -la /build/kernel/ 2>/dev/null || echo 'No kernel cache found'
echo ''
echo 'Cache sizes:'
du -sh /build/cache /build/source /build/kernel 2>/dev/null || true
"
volumes:
# New cached volumes
build-cache:
source-cache:
kernel-cache:
target-cache:
# Legacy volumes (for fallback)
github-cache:
kernel-cache-legacy: