FROM ubuntu:22.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive ENV MAAS_DBUSER=maas ENV MAAS_DBPASS=maas ENV MAAS_DBNAME=maasdb # Install system dependencies RUN apt-get update && apt-get install -y \ software-properties-common \ postgresql \ postgresql-contrib \ python3 \ python3-pip \ python3-venv \ nginx \ supervisor \ net-tools \ bridge-utils \ vlan \ iptables \ dnsmasq \ openvswitch-switch \ qemu-kvm \ libvirt-daemon-system \ libvirt-clients \ curl \ wget \ gnupg2 \ lsb-release \ && rm -rf /var/lib/apt/lists/* # Add MAAS PPA and install MAAS RUN add-apt-repository ppa:maas/3.4 -y && \ apt-get update && \ apt-get install -y maas maas-dhcp maas-dns maas-proxy && \ rm -rf /var/lib/apt/lists/* # Create Python virtual environment RUN python3 -m venv /opt/maas-env ENV PATH="/opt/maas-env/bin:$PATH" # Install Python dependencies COPY requirements.txt /tmp/ RUN pip install --no-cache-dir -r /tmp/requirements.txt # Create necessary directories RUN mkdir -p /opt/maas-config /var/log/supervisor /opt/scripts # Copy configuration files COPY config/ /opt/maas-config/ COPY scripts/ /opt/scripts/ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Set up PostgreSQL RUN service postgresql start && \ sudo -u postgres createuser --createdb $MAAS_DBUSER && \ sudo -u postgres psql -c "ALTER USER $MAAS_DBUSER WITH PASSWORD '$MAAS_DBPASS';" && \ sudo -u postgres createdb $MAAS_DBNAME --owner $MAAS_DBUSER # Initialize MAAS RUN service postgresql start && \ maas init region+rack --database-uri postgresql://$MAAS_DBUSER:$MAAS_DBPASS@localhost/$MAAS_DBNAME && \ maas createadmin --username admin --password admin --email admin@example.com # Expose ports EXPOSE 5240 5241 5242 5243 5248 5250 67 53 80 443 8080 9090 # Set working directory WORKDIR /opt/scripts # Start supervisor CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]