particle-os/02-installer-bootc-tui/Containerfile
2025-08-07 01:04:22 -07:00

175 lines
No EOL
7.8 KiB
Docker

# Debian Atomic Terminal Installer
# Builds a minimal bootable image with terminal-based installer
FROM debian:bookworm-slim
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV APT_CACHER_NG_PROXY=${APT_CACHER_NG_PROXY:-}
# Configure apt-cacher-ng proxy if available
RUN if [ -n "$APT_CACHER_NG_PROXY" ]; then \
echo "Acquire::http::Proxy \"$APT_CACHER_NG_PROXY\";" > /etc/apt/apt.conf.d/99proxy && \
echo "Acquire::https::Proxy \"$APT_CACHER_NG_PROXY\";" >> /etc/apt/apt.conf.d/99proxy; \
fi
# Update and install essential packages
RUN apt-get update && apt-get install -y \
# Core system
systemd \
systemd-sysv \
systemd-resolved \
# Boot and kernel
linux-image-amd64 \
initramfs-tools \
grub-pc \
# Partitioning and filesystem tools
parted \
gdisk \
dosfstools \
e2fsprogs \
# Installation tools
debootstrap \
# Network tools
network-manager \
# Terminal tools
bash \
vim \
nano \
curl \
wget \
# Monitoring tools
htop \
iotop \
# Development tools (for debugging)
build-essential \
# Clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create minimal filesystem structure
RUN mkdir -p /{bin,boot,dev,etc,home,lib,lib64,media,mnt,opt,proc,root,run,sbin,srv,sys,tmp,usr,var}
# Copy installation script
COPY scripts/install.sh /usr/local/bin/install-debian-atomic
RUN chmod +x /usr/local/bin/install-debian-atomic
# Create a simple init script
RUN echo '#!/bin/bash' > /sbin/init && \
echo '# Simple init script for Debian Atomic Terminal Installer' >> /sbin/init && \
echo '' >> /sbin/init && \
echo 'echo "Debian Atomic Terminal Installer"' >> /sbin/init && \
echo 'echo "================================"' >> /sbin/init && \
echo 'echo ""' >> /sbin/init && \
echo '' >> /sbin/init && \
echo '# Mount necessary filesystems' >> /sbin/init && \
echo 'mount -t proc proc /proc' >> /sbin/init && \
echo 'mount -t sysfs sysfs /sys' >> /sbin/init && \
echo 'mount -t devtmpfs devtmpfs /dev' >> /sbin/init && \
echo '' >> /sbin/init && \
echo '# Start systemd' >> /sbin/init && \
echo 'exec /lib/systemd/systemd' >> /sbin/init
RUN chmod +x /sbin/init
# Create a welcome script
RUN echo '#!/bin/bash' > /usr/local/bin/welcome && \
echo 'clear' >> /usr/local/bin/welcome && \
echo 'echo "Welcome to Debian Atomic Terminal Installer"' >> /usr/local/bin/welcome && \
echo 'echo "==========================================="' >> /usr/local/bin/welcome && \
echo 'echo ""' >> /usr/local/bin/welcome && \
echo 'echo "This is a minimal bootable image for installing Debian Atomic."' >> /usr/local/bin/welcome && \
echo 'echo ""' >> /usr/local/bin/welcome && \
echo 'echo "Available commands:"' >> /usr/local/bin/welcome && \
echo 'echo " install-debian-atomic - Run the automated installer"' >> /usr/local/bin/welcome && \
echo 'echo " welcome - Show this message"' >> /usr/local/bin/welcome && \
echo 'echo " bash - Open a shell"' >> /usr/local/bin/welcome && \
echo 'echo ""' >> /usr/local/bin/welcome && \
echo 'echo "To start the installation, run:"' >> /usr/local/bin/welcome && \
echo 'echo " sudo install-debian-atomic"' >> /usr/local/bin/welcome && \
echo 'echo ""' >> /usr/local/bin/welcome
RUN chmod +x /usr/local/bin/welcome
# Set up systemd services
RUN systemctl enable systemd-networkd
RUN systemctl enable systemd-resolved
# Create a simple systemd service for the installer
RUN echo '[Unit]' > /etc/systemd/system/installer.service && \
echo 'Description=Debian Atomic Terminal Installer' >> /etc/systemd/system/installer.service && \
echo 'After=network.target' >> /etc/systemd/system/installer.service && \
echo '' >> /etc/systemd/system/installer.service && \
echo '[Service]' >> /etc/systemd/system/installer.service && \
echo 'Type=oneshot' >> /etc/systemd/system/installer.service && \
echo 'ExecStart=/usr/local/bin/welcome' >> /etc/systemd/system/installer.service && \
echo 'RemainAfterExit=yes' >> /etc/systemd/system/installer.service && \
echo '' >> /etc/systemd/system/installer.service && \
echo '[Install]' >> /etc/systemd/system/installer.service && \
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/installer.service
# Enable the installer service
RUN systemctl enable installer.service
# Set up networking
RUN echo '[Match]' > /etc/systemd/network/20-wired.network && \
echo 'Name=en*' >> /etc/systemd/network/20-wired.network && \
echo '' >> /etc/systemd/network/20-wired.network && \
echo '[Network]' >> /etc/systemd/network/20-wired.network && \
echo 'DHCP=yes' >> /etc/systemd/network/20-wired.network
# Create a simple boot configuration
RUN mkdir -p /boot/grub
RUN echo 'set timeout=5' > /boot/grub/grub.cfg && \
echo 'set default=0' >> /boot/grub/grub.cfg && \
echo '' >> /boot/grub/grub.cfg && \
echo 'menuentry "Debian Atomic Terminal Installer" {' >> /boot/grub/grub.cfg && \
echo ' linux /boot/vmlinuz root=/dev/sda1 ro console=ttyS0 console=tty0' >> /boot/grub/grub.cfg && \
echo ' initrd /boot/initrd.img' >> /boot/grub/grub.cfg && \
echo '}' >> /boot/grub/grub.cfg && \
echo '' >> /boot/grub/grub.cfg && \
echo 'menuentry "Debian Atomic Terminal Installer (Debug)" {' >> /boot/grub/grub.cfg && \
echo ' linux /boot/vmlinuz root=/dev/sda1 ro console=ttyS0 console=tty0 debug' >> /boot/grub/grub.cfg && \
echo ' initrd /boot/initrd.img' >> /boot/grub/grub.cfg && \
echo '}' >> /boot/grub/grub.cfg
# Set up basic configuration
RUN echo "debian-atomic-installer" > /etc/hostname
RUN echo "127.0.0.1 localhost debian-atomic-installer" > /etc/hosts
# Create a simple motd
RUN echo 'Debian Atomic Terminal Installer' > /etc/motd && \
echo '================================' >> /etc/motd && \
echo '' >> /etc/motd && \
echo 'This is a minimal bootable image for installing Debian Atomic.' >> /etc/motd && \
echo '' >> /etc/motd && \
echo "Run 'install-debian-atomic' to start the installation process." >> /etc/motd
# Set up basic user environment
RUN echo 'export PS1="\[\033[01;32m\]\u@debian-atomic-installer\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "' >> /root/.bashrc
# Create a simple help script
RUN echo '#!/bin/bash' > /usr/local/bin/help && \
echo 'echo "Debian Atomic Terminal Installer - Help"' >> /usr/local/bin/help && \
echo 'echo "======================================"' >> /usr/local/bin/help && \
echo 'echo ""' >> /usr/local/bin/help && \
echo 'echo "This is a minimal bootable image for installing Debian Atomic."' >> /usr/local/bin/help && \
echo 'echo ""' >> /usr/local/bin/help && \
echo 'echo "Installation Process:"' >> /usr/local/bin/help && \
echo 'echo "1. Boot this image in a VM or on target hardware"' >> /usr/local/bin/help && \
echo 'echo "2. Run: sudo install-debian-atomic"' >> /usr/local/bin/help && \
echo 'echo "3. Follow the prompts to partition and install"' >> /usr/local/bin/help && \
echo 'echo "4. Reboot into the new system"' >> /usr/local/bin/help && \
echo 'echo ""' >> /usr/local/bin/help && \
echo 'echo "Available Commands:"' >> /usr/local/bin/help && \
echo 'echo " install-debian-atomic - Run the automated installer"' >> /usr/local/bin/help && \
echo 'echo " help - Show this help"' >> /usr/local/bin/help && \
echo 'echo " welcome - Show welcome message"' >> /usr/local/bin/help && \
echo 'echo " bash - Open a shell"' >> /usr/local/bin/help && \
echo 'echo ""' >> /usr/local/bin/help && \
echo 'echo "For more information, see the README.md file."' >> /usr/local/bin/help
RUN chmod +x /usr/local/bin/help
# Set the default command
CMD ["/lib/systemd/systemd"]