Skip to content

Commit b233311

Browse files
committed
docker-cs: Add Dockerfile and scripts
1 parent a243fc8 commit b233311

4 files changed

Lines changed: 124 additions & 0 deletions

File tree

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM ubuntu:22.04
2+
MAINTAINER Wei Zhou <ustcweizhou@gmail.com>
3+
4+
ENV DEBIAN_FRONTEND noninteractive
5+
6+
RUN apt update -qq && \
7+
apt upgrade -y && \
8+
apt install -y curl iproute2 net-tools iputils-ping apt-transport-https tini openssh-server
9+
10+
RUN echo "deb http://download.cloudstack.org/ubuntu jammy 4.18" > /etc/apt/sources.list.d/cloudstack.list && \
11+
curl -L http://download.cloudstack.org/release.asc -o /etc/apt/trusted.gpg.d/cloudstack.asc && \
12+
apt update -qq && \
13+
apt install -y cloudstack-management && \
14+
apt install -y cloudstack-usage
15+
16+
COPY bin /usr/bin
17+
COPY entrypoint.sh /entrypoint.sh
18+
19+
EXPOSE 8080 8250 8096 22
20+
21+
ENTRYPOINT ["tini", "--", "/entrypoint.sh"]

bin/cloudstack-management

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
SERVICE="cloudstack-management"
4+
DESC="management server"
5+
6+
MGMT_SERVICE="cloudstack-management"
7+
USAGE_SERVICE="cloudstack-usage"
8+
9+
find_pids() {
10+
service=$1
11+
pids=$(ps aux |grep "[j]ava" |grep "$service" |awk '{print $2}')
12+
echo $pids
13+
}
14+
15+
stop_pid() {
16+
pids=$1
17+
for pid in $pids;do
18+
kill $pid
19+
done
20+
}
21+
22+
start_management() {
23+
source /etc/default/cloudstack-management
24+
tini -- /usr/bin/java $JAVA_DEBUG $JAVA_OPTS -cp $CLASSPATH $BOOTSTRAP_CLASS > /dev/null 2>&1 &
25+
}
26+
27+
start_usage() {
28+
source /etc/default/cloudstack-usage
29+
tini -- /usr/bin/java -Dpid=$$ $JAVA_OPTS $JAVA_DEBUG -cp $CLASSPATH $JAVA_CLASS > /dev/null 2>&1 &
30+
}
31+
32+
start_service() {
33+
service=$1
34+
if [ "$service" = "$MGMT_SERVICE" ];then
35+
start_management
36+
elif [ "$service" = "$USAGE_SERVICE" ];then
37+
start_usage
38+
fi
39+
}
40+
41+
process_status() {
42+
service=$1
43+
pids=$(find_pids $SERVICE)
44+
if [ "$pids" != "" ];then
45+
echo >&2 "CloudStack $DESC is running with pid $pids"
46+
else
47+
echo >&2 "CloudStack $DESC is stopped"
48+
fi
49+
}
50+
51+
process() {
52+
action=$1
53+
if [ "$action" = "status" ] || [ "$action" = "" ];then
54+
process_status $SERVICE
55+
fi
56+
pids=$(find_pids $SERVICE)
57+
if [ "$pids" != "" ];then
58+
if [ "$action" = "start" ];then
59+
echo >&2 "CloudStack $DESC is running with pid $pids"
60+
action=
61+
elif [ "$action" = "stop" ] || [ "$action" = "restart" ];then
62+
echo >&2 "Stopping $DESC with pid $pids"
63+
stop_pid $pids
64+
echo >&2 "Stopped $DESC with pid $pids"
65+
fi
66+
fi
67+
if [ "$action" = "start" ] || [ "$action" = "restart" ];then
68+
echo >&2 "Starting $DESC"
69+
start_service $SERVICE
70+
echo >&2 "Started $DESC"
71+
fi
72+
}
73+
74+
process $1

cloudstack-mgt01.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "2.4"
2+
services:
3+
mgt01:
4+
image: ubuntu:22.04
5+
hostname: mgt01
6+
networks:
7+
cs:
8+
ipv4_address: 10.0.34.217
9+
entrypoint: ["tail", "-f", "/dev/null"]
10+
expose:
11+
- 8250
12+
- 8080
13+
- 8096
14+
- 22
15+
16+
networks:
17+
cs:
18+
driver: macvlan
19+
driver_opts:
20+
parent: eth0
21+
ipam:
22+
config:
23+
- subnet: "10.0.32.0/20"
24+
gateway: "10.0.32.1"

entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
service ssh restart
4+
5+
tail -f /dev/null

0 commit comments

Comments
 (0)