Initial commit: Alpine Zero-OS initramfs build system with cleaned Docker configuration
This commit is contained in:
71
build/Dockerfile.alpine
Normal file
71
build/Dockerfile.alpine
Normal file
@@ -0,0 +1,71 @@
|
||||
# Alpine-based Zero-OS Initramfs Builder
|
||||
FROM alpine:3.22
|
||||
|
||||
# Set build arguments
|
||||
ARG TARGETARCH=amd64
|
||||
ARG BUILDMODE=debug
|
||||
ARG MINIMAL_MODE=false
|
||||
|
||||
# Set environment variables
|
||||
ENV BUILDMODE=${BUILDMODE}
|
||||
ENV TARGETARCH=${TARGETARCH}
|
||||
ENV MINIMAL_MODE=${MINIMAL_MODE}
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache \
|
||||
# Build tools
|
||||
build-base \
|
||||
linux-headers \
|
||||
cmake \
|
||||
git \
|
||||
wget \
|
||||
curl \
|
||||
cpio \
|
||||
xz \
|
||||
gzip \
|
||||
bc \
|
||||
perl \
|
||||
python3 \
|
||||
# Kernel build dependencies
|
||||
linux-lts-dev \
|
||||
linux-lts \
|
||||
elfutils-dev \
|
||||
openssl-dev \
|
||||
flex \
|
||||
bison \
|
||||
# Archive tools
|
||||
tar \
|
||||
bzip2 \
|
||||
unzip \
|
||||
# Text processing
|
||||
sed \
|
||||
grep \
|
||||
findutils \
|
||||
# JSON processing for GitHub API
|
||||
jq
|
||||
|
||||
# Create directories
|
||||
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /build
|
||||
|
||||
# Copy build scripts and configs
|
||||
COPY scripts/ /build/scripts/
|
||||
COPY configs/ /build/configs/
|
||||
|
||||
# Make scripts executable
|
||||
RUN chmod +x /build/scripts/*.sh
|
||||
|
||||
# Create build configuration
|
||||
RUN echo "BUILDMODE=${BUILDMODE}" > /build/build.conf && \
|
||||
echo "TARGETARCH=${TARGETARCH}" >> /build/build.conf && \
|
||||
echo "MINIMAL_MODE=${MINIMAL_MODE}" >> /build/build.conf && \
|
||||
echo "INITRAMFS_ROOT=/build/initramfs" >> /build/build.conf && \
|
||||
echo "KERNEL_DIR=/build/kernel" >> /build/build.conf && \
|
||||
echo "OUTPUT_DIR=/build/output" >> /build/build.conf && \
|
||||
echo "CONFIG_DIR=/build/configs" >> /build/build.conf
|
||||
|
||||
# Default command
|
||||
CMD ["/build/scripts/build-initramfs.sh"]
|
||||
102
build/Dockerfile.cached
Normal file
102
build/Dockerfile.cached
Normal file
@@ -0,0 +1,102 @@
|
||||
# Multi-stage Alpine Zero-OS Builder with Smart Caching
|
||||
# Stage 1: Base build environment (cached until Alpine version changes)
|
||||
FROM alpine:3.22 AS base-builder
|
||||
|
||||
# Install build dependencies (expensive, cache this layer)
|
||||
RUN apk add --no-cache \
|
||||
# Build tools
|
||||
build-base \
|
||||
linux-headers \
|
||||
cmake \
|
||||
git \
|
||||
wget \
|
||||
curl \
|
||||
cpio \
|
||||
xz \
|
||||
gzip \
|
||||
bc \
|
||||
perl \
|
||||
python3 \
|
||||
# Kernel build dependencies
|
||||
linux-lts-dev \
|
||||
linux-lts \
|
||||
elfutils-dev \
|
||||
openssl-dev \
|
||||
flex \
|
||||
bison \
|
||||
# Archive tools
|
||||
tar \
|
||||
bzip2 \
|
||||
unzip \
|
||||
# Text processing
|
||||
sed \
|
||||
grep \
|
||||
findutils \
|
||||
jq \
|
||||
# Go and Rust for source compilation
|
||||
go \
|
||||
rust \
|
||||
cargo
|
||||
|
||||
# Create standard directories
|
||||
RUN mkdir -p /build/initramfs /build/kernel /build/output /build/github /build/configs/zinit /mnt/zinit /build/source /build/cache
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Stage 2: Zero-OS components (cached until source repos change)
|
||||
FROM base-builder AS components-builder
|
||||
|
||||
# Copy component compilation script
|
||||
COPY scripts/compile-components.sh /build/scripts/
|
||||
RUN chmod +x /build/scripts/compile-components.sh
|
||||
|
||||
# Create a marker file to track component compilation
|
||||
RUN echo "$(date)" > /build/components-build-time
|
||||
|
||||
# This stage will be cached unless we explicitly rebuild components
|
||||
|
||||
# Stage 3: Kernel builder (cached until kernel version/config changes)
|
||||
FROM components-builder AS kernel-builder
|
||||
|
||||
# Copy kernel configuration and version
|
||||
COPY configs/kernel-version /build/configs/
|
||||
COPY configs/kernel-config-generic /build/configs/
|
||||
COPY scripts/build-kernel.sh /build/scripts/
|
||||
RUN chmod +x /build/scripts/build-kernel.sh
|
||||
|
||||
# Create kernel build marker
|
||||
RUN echo "Kernel: $(cat /build/configs/kernel-version)" > /build/kernel-build-marker
|
||||
|
||||
# This stage caches kernel source download and basic setup
|
||||
|
||||
# Stage 4: Final builder (lightweight layer for initramfs assembly)
|
||||
FROM kernel-builder AS final-builder
|
||||
|
||||
# Copy all scripts and configs
|
||||
COPY scripts/ /build/scripts/
|
||||
COPY configs/ /build/configs/
|
||||
|
||||
# Make all scripts executable
|
||||
RUN chmod +x /build/scripts/*.sh
|
||||
|
||||
# Set build arguments
|
||||
ARG TARGETARCH=amd64
|
||||
ARG BUILDMODE=debug
|
||||
ARG MINIMAL_MODE=false
|
||||
|
||||
# Set environment variables
|
||||
ENV BUILDMODE=${BUILDMODE}
|
||||
ENV TARGETARCH=${TARGETARCH}
|
||||
ENV MINIMAL_MODE=${MINIMAL_MODE}
|
||||
|
||||
# Create build configuration
|
||||
RUN echo "BUILDMODE=${BUILDMODE}" > /build/build.conf && \
|
||||
echo "TARGETARCH=${TARGETARCH}" >> /build/build.conf && \
|
||||
echo "MINIMAL_MODE=${MINIMAL_MODE}" >> /build/build.conf && \
|
||||
echo "INITRAMFS_ROOT=/build/initramfs" >> /build/build.conf && \
|
||||
echo "KERNEL_DIR=/build/kernel" >> /build/build.conf && \
|
||||
echo "OUTPUT_DIR=/build/output" >> /build/build.conf && \
|
||||
echo "CONFIG_DIR=/build/configs" >> /build/build.conf
|
||||
|
||||
# Default command
|
||||
CMD ["/build/scripts/build-initramfs.sh"]
|
||||
126
build/docker-compose.yml
Normal file
126
build/docker-compose.yml
Normal file
@@ -0,0 +1,126 @@
|
||||
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}"
|
||||
image: zero-os-alpine-builder:cached-${BUILDMODE:-debug}
|
||||
container_name: zero-os-alpine-builder-cached
|
||||
privileged: true
|
||||
volumes:
|
||||
# Mount source configs and scripts (read-only for cache efficiency)
|
||||
- ../configs:/build/configs:ro
|
||||
- ../scripts:/build/scripts:ro
|
||||
# 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}"
|
||||
image: zero-os-alpine-builder:legacy
|
||||
container_name: zero-os-alpine-builder-legacy
|
||||
privileged: true
|
||||
volumes:
|
||||
- ../configs:/build/configs:ro
|
||||
- ../scripts:/build/scripts:ro
|
||||
- ../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
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- ../configs:/build/configs
|
||||
- ../scripts:/build/scripts
|
||||
- ../output:/build/output
|
||||
- build-cache:/build/cache
|
||||
- source-cache:/build/source
|
||||
- kernel-cache:/build/kernel
|
||||
- ../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:ro
|
||||
- ../scripts:/build/scripts:ro
|
||||
- ../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:
|
||||
|
||||
# Legacy volumes (for fallback)
|
||||
github-cache:
|
||||
kernel-cache-legacy:
|
||||
Reference in New Issue
Block a user