FROM ubuntu:24.04 RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates tzdata curl locales gettext-base systemd systemd-sysv && \ rm -rf /var/lib/apt/lists/* # Configure systemd for container use RUN cd /lib/systemd/system/sysinit.target.wants/ && \ ls | grep -v systemd-tmpfiles-setup | xargs rm -f && \ rm -f /lib/systemd/system/multi-user.target.wants/* && \ rm -f /etc/systemd/system/*.wants/* && \ rm -f /lib/systemd/system/local-fs.target.wants/* && \ rm -f /lib/systemd/system/sockets.target.wants/*udev* && \ rm -f /lib/systemd/system/sockets.target.wants/*initctl* && \ rm -f /lib/systemd/system/basic.target.wants/* && \ rm -f /lib/systemd/system/anaconda.target.wants/* # Create bzzz directories RUN mkdir -p /opt/bzzz /opt/bzzz/.bzzz /etc/systemd/system # BZZZ binary COPY ./build/bzzz /opt/bzzz/bzzz RUN chmod +x /opt/bzzz/bzzz # Config template COPY ./config.yml.tmpl /opt/bzzz/.bzzz/config.yml.tmpl # Create systemd service file RUN cat > /etc/systemd/system/bzzz.service << 'EOF' [Unit] Description=BZZZ P2P Task Coordination System After=network.target Wants=network-online.target [Service] Type=simple User=root WorkingDirectory=/opt/bzzz ExecStart=/opt/bzzz/bzzz -config /opt/bzzz/.bzzz/config.yml Restart=always RestartSec=10 StandardOutput=journal StandardError=journal SyslogIdentifier=bzzz [Install] WantedBy=multi-user.target EOF # Enable the service RUN systemctl enable bzzz.service # Create startup script that renders config and starts systemd RUN cat > /opt/bzzz/startup.sh << 'EOF' #!/bin/bash set -e # Render config from template envsubst < /opt/bzzz/.bzzz/config.yml.tmpl > /opt/bzzz/.bzzz/config.yml # Start systemd exec /lib/systemd/systemd EOF RUN chmod +x /opt/bzzz/startup.sh # Working directory WORKDIR /opt/bzzz # Use systemd as init system ENTRYPOINT ["/opt/bzzz/startup.sh"]