Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 9 additions & 61 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,77 +1,25 @@
FROM public.ecr.aws/docker/library/ubuntu:22.04
# See https://github.com/apache/cloudstack/blob/main/tools/docker/Dockerfile
FROM docker.io/apache/cloudstack-simulator:4.22.1.0

ENV DEBIAN_FRONTEND noninteractive

ARG src_url=https://github.com/apache/cloudstack/archive/refs/tags/4.19.1.3.tar.gz

RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections; \
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections;

RUN apt-get -y update && apt-get install -y --no-install-recommends \
genisoimage \
libffi-dev \
libssl-dev \
sudo \
ipmitool \
maven \
netcat \
openjdk-11-jdk \
python3 \
python3-dev \
python3-mysql.connector \
python3-pip \
python3-setuptools \
python3-paramiko \
supervisor \
RUN apt-get -y update && apt-get upgrade -y && apt-get install -y --no-install-recommends \
wget \
nginx \
jq \
mysql-server \
openssh-client \
build-essential \
npm \
nodejs \
pipx \
netcat-traditional \
&& apt-get clean all && rm -rf /var/lib/apt/lists/*;

# TODO: check if and why this is needed
RUN mkdir -p /root/.ssh \
&& chmod 0700 /root/.ssh \
&& ssh-keygen -t rsa -N "" -f id_rsa.cloud

RUN mkdir -p /var/run/mysqld; \
chown mysql /var/run/mysqld;

RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot password ''

RUN wget $src_url -O /opt/cloudstack.tar.gz; \
mkdir -p /opt/cloudstack; \
tar xvzf /opt/cloudstack.tar.gz -C /opt/cloudstack --strip-components=1

WORKDIR /opt/cloudstack

RUN ln -s /usr/bin/python3 /usr/local/bin/python
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
RUN mvn -Pdeveloper -Dsimulator dependency:go-offline
RUN mvn -pl client jetty:run -Dsimulator -Djetty.skip -Dorg.eclipse.jetty.annotations.maxWait=120

COPY zones.cfg /opt/zones.cfg

RUN (/usr/bin/mysqld_safe &); \
sleep 5; \
mvn -Pdeveloper -pl developer -Ddeploydb; \
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
mvn -Pdeveloper,marvin -pl :cloud-marvin; \
MARVIN_FILE=$(find /opt/cloudstack/tools/marvin/dist/ -name "Marvin*.tar.gz"); \
pip install wheel; \
pip install $MARVIN_FILE;

COPY nginx_default.conf /etc/nginx/sites-available/default
RUN pip install cs

RUN pipx install cs

COPY run.sh /opt/run.sh
COPY deploy.sh /opt/deploy.sh
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

RUN cd ui && npm install && npm run build
COPY supervisord_nginx.conf /etc/supervisor/conf.d/nginx.conf

RUN /opt/deploy.sh

Expand Down
21 changes: 15 additions & 6 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
#!/bin/bash +x
set -euo pipefail
export PATH="/root/.local/bin:$PATH"

/usr/bin/mysqld_safe &
cd /opt/cloudstack && mvn -pl client jetty:run -Dsimulator -Dorg.eclipse.jetty.annotations.maxWait=120 &
# Run the CloudStack Simulator
/usr/bin/supervisord --silent &

echo "--- Waiting for CloudStack Simulator to start ---"
sleep 30
until nc -z localhost 8096; do
echo "waiting for port 8096..."
echo "--- ...waiting for port 8096... ---"
sleep 3
done

sleep 3
python3 /opt/cloudstack/tools/marvin/marvin/deployDataCenter.py -i /opt/zones.cfg
sleep 10
echo "--- Deploying CloudStack Simulator Zones (this will take some minutes...) ---"
python3 /root/tools/marvin/marvin/deployDataCenter.py -i /opt/zones.cfg

export CLOUDSTACK_ENDPOINT=http://127.0.0.1:8096
export CLOUDSTACK_KEY=dummy
export CLOUDSTACK_SECRET=dummy

# Add Simulator to supported hypervisors exclusively
cs updateConfiguration name=hypervisor.list value=Simulator

# Stop the CloudStack Simulator
supervisorctl stop all

echo "--- CloudStack Simulator Zones deployed ---"
9 changes: 7 additions & 2 deletions nginx_default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ upstream cloudstack-backend {
server 127.0.0.1:8080;
}

upstream cloudstack-ui {
server 127.0.0.1:5050;
}

server {
listen 8888 default_server;
server_name _;
Expand All @@ -20,8 +24,9 @@ server {
location /client {
proxy_pass http://cloudstack-backend;
}

location / {
root /opt/cloudstack/ui/dist;
index index.html;
proxy_set_header Host localhost;
proxy_pass http://cloudstack-ui;
}
}
28 changes: 0 additions & 28 deletions supervisord.conf

This file was deleted.

12 changes: 12 additions & 0 deletions supervisord_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[program:nginx]
command=/usr/sbin/nginx
autostart=true
autorestart=false
user=root

[program:run]
command=/opt/run.sh
startsecs=0
autorestart=false
startretries=1
user=root
Loading