Create Dockerfile
Browse files- Dockerfile +74 -0
Dockerfile
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ubuntu:22.04
|
| 2 |
+
|
| 3 |
+
# Set environment variables
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
ENV MAAS_DBUSER=maas
|
| 6 |
+
ENV MAAS_DBPASS=maas
|
| 7 |
+
ENV MAAS_DBNAME=maasdb
|
| 8 |
+
|
| 9 |
+
# Install system dependencies
|
| 10 |
+
RUN apt-get update && apt-get install -y \
|
| 11 |
+
software-properties-common \
|
| 12 |
+
postgresql \
|
| 13 |
+
postgresql-contrib \
|
| 14 |
+
python3 \
|
| 15 |
+
python3-pip \
|
| 16 |
+
python3-venv \
|
| 17 |
+
nginx \
|
| 18 |
+
supervisor \
|
| 19 |
+
net-tools \
|
| 20 |
+
bridge-utils \
|
| 21 |
+
vlan \
|
| 22 |
+
iptables \
|
| 23 |
+
dnsmasq \
|
| 24 |
+
openvswitch-switch \
|
| 25 |
+
qemu-kvm \
|
| 26 |
+
libvirt-daemon-system \
|
| 27 |
+
libvirt-clients \
|
| 28 |
+
curl \
|
| 29 |
+
wget \
|
| 30 |
+
gnupg2 \
|
| 31 |
+
lsb-release \
|
| 32 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
+
|
| 34 |
+
# Add MAAS PPA and install MAAS
|
| 35 |
+
RUN add-apt-repository ppa:maas/3.4 -y && \
|
| 36 |
+
apt-get update && \
|
| 37 |
+
apt-get install -y maas maas-dhcp maas-dns maas-proxy && \
|
| 38 |
+
rm -rf /var/lib/apt/lists/*
|
| 39 |
+
|
| 40 |
+
# Create Python virtual environment
|
| 41 |
+
RUN python3 -m venv /opt/maas-env
|
| 42 |
+
ENV PATH="/opt/maas-env/bin:$PATH"
|
| 43 |
+
|
| 44 |
+
# Install Python dependencies
|
| 45 |
+
COPY requirements.txt /tmp/
|
| 46 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
| 47 |
+
|
| 48 |
+
# Create necessary directories
|
| 49 |
+
RUN mkdir -p /opt/maas-config /var/log/supervisor /opt/scripts
|
| 50 |
+
|
| 51 |
+
# Copy configuration files
|
| 52 |
+
COPY config/ /opt/maas-config/
|
| 53 |
+
COPY scripts/ /opt/scripts/
|
| 54 |
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 55 |
+
|
| 56 |
+
# Set up PostgreSQL
|
| 57 |
+
RUN service postgresql start && \
|
| 58 |
+
sudo -u postgres createuser --createdb $MAAS_DBUSER && \
|
| 59 |
+
sudo -u postgres psql -c "ALTER USER $MAAS_DBUSER WITH PASSWORD '$MAAS_DBPASS';" && \
|
| 60 |
+
sudo -u postgres createdb $MAAS_DBNAME --owner $MAAS_DBUSER
|
| 61 |
+
|
| 62 |
+
# Initialize MAAS
|
| 63 |
+
RUN service postgresql start && \
|
| 64 |
+
maas init region+rack --database-uri postgresql://$MAAS_DBUSER:$MAAS_DBPASS@localhost/$MAAS_DBNAME && \
|
| 65 |
+
maas createadmin --username admin --password admin --email admin@example.com
|
| 66 |
+
|
| 67 |
+
# Expose ports
|
| 68 |
+
EXPOSE 5240 5241 5242 5243 5248 5250 67 53 80 443 8080 9090
|
| 69 |
+
|
| 70 |
+
# Set working directory
|
| 71 |
+
WORKDIR /opt/scripts
|
| 72 |
+
|
| 73 |
+
# Start supervisor
|
| 74 |
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|