debian-bootc-base-images/Containerfile
2025-08-30 12:36:18 -07:00

92 lines
3.4 KiB
Docker

# Multi-stage build for Debian minimal bootc base images
# Stage 1: Repository setup with apt-cache-ng proxy
FROM debian:sid AS repos
# Build argument for apt-cache-ng proxy (can be empty to disable)
ARG APT_CACHER_NG_PROXY="http://192.168.1.101:3142"
# Copy our repository configuration
COPY debian.repo /etc/apt/sources.list.d/
# Replace the proxy URL placeholder with the actual value
RUN if [ -n "$APT_CACHER_NG_PROXY" ]; then \
sed -i "s|__PROXY_URL__|$APT_CACHER_NG_PROXY|g" /etc/apt/sources.list.d/debian.repo; \
echo "Acquire::http::Proxy \"$APT_CACHER_NG_PROXY\";" > /etc/apt/apt.conf.d/99proxy; \
else \
# If no proxy, replace with direct URLs
sed -i "s|__PROXY_URL__/debian|http://deb.debian.org/debian|g" /etc/apt/sources.list.d/debian.repo; \
sed -i "s|__PROXY_URL__/debian-security|http://security.debian.org/debian-security|g" /etc/apt/sources.list.d/debian.repo; \
fi
# Stage 2: Builder image with tools
FROM debian:sid AS builder
# Copy repository configuration from repos stage
COPY --from=repos /etc/apt/sources.list.d/ /etc/apt/sources.list.d/
COPY --from=repos /etc/apt/apt.conf.d/ /etc/apt/apt.conf.d/
# Install build dependencies (excluding apt-ostree since we'll copy it)
RUN apt-get update && apt-get install -y \
selinux-policy-default \
python3 \
polkitd \
pkexec \
libpolkit-gobject-1-0 \
ostree \
&& rm -rf /var/lib/apt/lists/*
# Copy our local apt-ostree binary
COPY apt-ostree /usr/local/bin/
RUN chmod +x /usr/local/bin/apt-ostree
# Copy our tool and manifests
COPY debian-bootc-base-imagectl /usr/local/bin/
COPY install-manifests /usr/local/bin/
RUN chmod +x /usr/local/bin/debian-bootc-base-imagectl /usr/local/bin/install-manifests
# Copy the manifest directories and files
COPY minimal/ /minimal/
COPY standard/ /standard/
COPY minimal-plus/ /minimal-plus/
COPY iot/ /iot/
COPY debian-includes/ /debian-includes/
COPY *.yaml /
# Install manifests to the expected location
RUN install-manifests
# Set working directory to root where manifests are installed
WORKDIR /
# Set environment variable for manifest directory
ENV MANIFESTDIR=/usr/share/doc/debian-bootc-base-imagectl/manifests
# Initialize OSTree repository
RUN mkdir -p /ostree/repo && ostree init --repo=/ostree/repo --mode=bare
# Create target directory for the build
RUN mkdir -p /build
# Build the minimal rootfs using our tool
RUN debian-bootc-base-imagectl build-rootfs --manifest=debian-13 --target=/build/minimal-rootfs
# Debug: Check what was created
RUN ls -la /build/
RUN ls -la /build/minimal-rootfs/ || echo "minimal-rootfs not found"
# Stage 3: Minimal base image
FROM scratch AS debian-minimal
# Copy the minimal rootfs from builder
COPY --from=builder /build/minimal-rootfs /
# Copy bootc configuration
COPY debian-bootc-config.json /etc/debian-bootc-config.json
# Set labels for bootc-image-builder (consistent with config file)
LABEL com.debian.bootc=true
LABEL ostree.bootable=true
LABEL containers.bootc=1
LABEL bootc.diskimage-builder=quay.io/centos-bootc/bootc-image-builder
LABEL debian.id=debian
LABEL debian.version-id=sid
LABEL org.opencontainers.image.title="Debian Minimal Bootc Base Image"
LABEL org.opencontainers.image.description="Minimal Debian base image for bootc ecosystem"
LABEL org.opencontainers.image.vendor="Debian Project"
LABEL org.opencontainers.image.source="https://github.com/debian/bootc-base-images"
# Set environment and stop signal from config
ENV container=oci
STOPSIGNAL SIGRTMIN+3