zeus
4 years ago
9 changed files with 359 additions and 0 deletions
@ -0,0 +1,62 @@ |
|||||
|
#FROM alpine:3.11 |
||||
|
FROM node:alpine |
||||
|
|
||||
|
LABEL MAINTAINERS="Guillaume Scheibel <guillaume.scheibel@gmail.com>, Damien DUPORTAL <damien.duportal@gmail.com>" |
||||
|
|
||||
|
# Installing package required for the runtime |
||||
|
# build/llo-base-images/asciidoctor-alpine/docker-asciidoctor |
||||
|
RUN apk add --no-cache \ |
||||
|
bash \ |
||||
|
curl \ |
||||
|
ca-certificates \ |
||||
|
findutils \ |
||||
|
font-bakoma-ttf \ |
||||
|
git \ |
||||
|
graphviz \ |
||||
|
inotify-tools \ |
||||
|
make \ |
||||
|
python3 \ |
||||
|
py3-pillow \ |
||||
|
py3-setuptools \ |
||||
|
tzdata \ |
||||
|
unzip \ |
||||
|
build-base \ |
||||
|
libxml2-dev \ |
||||
|
which |
||||
|
|
||||
|
# Installing Python dependencies for additional |
||||
|
# functionnalities |
||||
|
RUN apk add --no-cache --virtual .pythonmakedepends \ |
||||
|
build-base \ |
||||
|
python3-dev \ |
||||
|
py3-pip \ |
||||
|
&& pip3 install --no-cache-dir \ |
||||
|
actdiag \ |
||||
|
pip install supervisor supervisor-stdout \ |
||||
|
'blockdiag[pdf]' \ |
||||
|
nwdiag \ |
||||
|
seqdiag \ |
||||
|
&& apk del -r --no-cache .pythonmakedepends |
||||
|
|
||||
|
RUN ln -s /usr/local/bin/node /usr/bin/node |
||||
|
|
||||
|
ADD supervisord.conf /etc/supervisor/supervisord.conf |
||||
|
ADD supervisord-iot.conf /etc/supervisor/conf.d/node-app.conf |
||||
|
ADD mpi_bootstrap /home/node |
||||
|
ADD startup.sh /home/node |
||||
|
|
||||
|
ADD ttyd /usr/bin |
||||
|
ADD ssl-ttyd /home/node/ssl-ttyd |
||||
|
|
||||
|
RUN mkdir -p /home/node/log \ |
||||
|
&& mkdir -p /home/node/crond \ |
||||
|
&& mkdir -p /home/node/run \ |
||||
|
&& chmod -R 755 /home/node \ |
||||
|
&& chown -R node.node /home/node |
||||
|
|
||||
|
WORKDIR /home/node |
||||
|
VOLUME /home/node |
||||
|
|
||||
|
EXPOSE 8080 8088 8084 3081 |
||||
|
|
||||
|
CMD ["/usr/bin/supervisord", "-c", "/home/node/startup.sh"] |
@ -0,0 +1,2 @@ |
|||||
|
#!/bin/bash |
||||
|
docker build -f Dockerfile -t hub.swarmlab.io:5443/playground-nodejs-swarm . |
@ -0,0 +1,72 @@ |
|||||
|
#!/bin/sh |
||||
|
|
||||
|
ROLE="undefined" |
||||
|
MPI_MASTER_SERVICE_NAME="mpi2_master" |
||||
|
MPI_WORKER_SERVICE_NAME="mpi2_worker" |
||||
|
|
||||
|
####################### |
||||
|
# ARGUMENTS PARSER |
||||
|
|
||||
|
while [ "$1" != "" ]; |
||||
|
do |
||||
|
PARAM=$(echo "$1" | awk -F= '{print $1}') |
||||
|
VALUE=$(echo "$1" | awk -F= '{print $2}') |
||||
|
|
||||
|
case $PARAM in |
||||
|
role) |
||||
|
[ "$VALUE" ] && ROLE=$VALUE |
||||
|
;; |
||||
|
|
||||
|
mpi_master_service_name) |
||||
|
[ "$VALUE" ] && MPI_MASTER_SERVICE_NAME=$VALUE |
||||
|
;; |
||||
|
|
||||
|
mpi_worker_service_name) |
||||
|
[ "$VALUE" ] && MPI_WORKER_SERVICE_NAME=$VALUE |
||||
|
;; |
||||
|
*) |
||||
|
echo "ERROR: unknown parameter \"$PARAM\"" |
||||
|
exit 1 |
||||
|
;; |
||||
|
esac |
||||
|
shift |
||||
|
done |
||||
|
|
||||
|
|
||||
|
|
||||
|
cat > /etc/opt/service_names <<- EOF |
||||
|
MPI_MASTER_SERVICE_NAME=${MPI_MASTER_SERVICE_NAME} |
||||
|
MPI_WORKER_SERVICE_NAME=${MPI_WORKER_SERVICE_NAME} |
||||
|
EOF |
||||
|
|
||||
|
case $ROLE in |
||||
|
"master") |
||||
|
|
||||
|
# Auto update default host file in background and dumb all output |
||||
|
auto_update_hosts "${HYDRA_HOST_FILE}" > /dev/null 2>&1 & |
||||
|
|
||||
|
/bin/bash /home/node/startup.sh |
||||
|
# Start ssh server |
||||
|
#/usr/sbin/sshd -D |
||||
|
;; |
||||
|
|
||||
|
|
||||
|
"worker") |
||||
|
|
||||
|
# Start ssh server in background |
||||
|
/usr/sbin/sshd -D & |
||||
|
|
||||
|
# Keep trying to connect to master node and stay there indefinitely so that master node can see |
||||
|
# the connected hosts that are ready for MPI work |
||||
|
while sleep 1 |
||||
|
do |
||||
|
# shellcheck disable=SC2086 |
||||
|
ssh -T -o "StrictHostKeyChecking no" \ |
||||
|
-i "${USER_HOME}/.ssh/id_rsa" \ |
||||
|
${USER}@${MPI_MASTER_SERVICE_NAME} \ |
||||
|
"tail -f /dev/null" |
||||
|
done |
||||
|
;; |
||||
|
*) |
||||
|
echo 'role argument only accepts "master" or "worker"' |
||||
|
esac |
@ -0,0 +1,22 @@ |
|||||
|
-----BEGIN CERTIFICATE----- |
||||
|
MIIDqzCCApOgAwIBAgIJAOCXdz+7wedQMA0GCSqGSIb3DQEBCwUAMGwxCzAJBgNV |
||||
|
BAYTAmdyMQ8wDQYDVQQIDAZhdHRpY2ExDzANBgNVBAcMBmF0aGVuczEOMAwGA1UE |
||||
|
CgwFc3dhcm0xETAPBgNVBAsMCHN3YXJtbGFiMRgwFgYDVQQDDA90dHkuc3dhcm1s |
||||
|
YWIuaW8wHhcNMjAwMzE3MTYyMzM3WhcNMzAwMzE1MTYyMzM3WjBsMQswCQYDVQQG |
||||
|
EwJncjEPMA0GA1UECAwGYXR0aWNhMQ8wDQYDVQQHDAZhdGhlbnMxDjAMBgNVBAoM |
||||
|
BXN3YXJtMREwDwYDVQQLDAhzd2FybWxhYjEYMBYGA1UEAwwPdHR5LnN3YXJtbGFi |
||||
|
LmlvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAycWkd5JDQNz8eJL7 |
||||
|
Py1r2V0GByMEnMJ40CZ1YG/FxCdjRI82jmKSzjEYLshY0yWZcYKmLvO3FAhKTQr0 |
||||
|
IkM0L/ocDAkpQZQzxwBORDeb09649U2IMAoDmzLx220JSYqMxNSibO4tzUKtkR16 |
||||
|
Vn/6X/+vLsWK0HVKLKOU/zMkLozlXnvitfOvQYREeStj3eS+At+klA9UofnCH3lK |
||||
|
a83yZ2nMS1MLITOLshePOr5BZ6kotXdH16hBKvQqSHPztof2ZCILXQwfKd3KLPRA |
||||
|
/Irz2aBFLKkczDLpBlr0yq8r340YOL1P5GWMApNrEAGIz8SRszGvRX9xJX3F50hT |
||||
|
QqfScwIDAQABo1AwTjAdBgNVHQ4EFgQUgs1c9ndtFr40m94/dX/ceMzrL2gwHwYD |
||||
|
VR0jBBgwFoAUgs1c9ndtFr40m94/dX/ceMzrL2gwDAYDVR0TBAUwAwEB/zANBgkq |
||||
|
hkiG9w0BAQsFAAOCAQEAngzEkQcn2XaOgfLZqn3/VG8OGcxAU4sMN5KwMQzL3sR+ |
||||
|
x6roGrjdE4B8t5HK68PE6mr/3i+vjcH3+di7qCK3RNM5UhvZEqRdRQAUCrDdsl7B |
||||
|
hM3nLVAPytgieT9Ul+Oq6WM4SNTPuVqpNa3VJ48FXl+DZh5P0Iqou5bnXi7/fC3+ |
||||
|
Y88k9dmPIvFBSVMcv5m08DIda8KVidCNdDRHSSVXd21ZBz0Xd0gwgWY3Gjl58a8T |
||||
|
rMNYUhJlQpjAbbeXSym0uXzB65zGpMPkpqfk3iFk6e/bvFR4n6pZ5OFH+Z2ke2al |
||||
|
kVC8K4DEpKfD0BgEmObebGQbFIv5lCHDvn0Nmp7gTQ== |
||||
|
-----END CERTIFICATE----- |
@ -0,0 +1,27 @@ |
|||||
|
-----BEGIN RSA PRIVATE KEY----- |
||||
|
MIIEpAIBAAKCAQEAycWkd5JDQNz8eJL7Py1r2V0GByMEnMJ40CZ1YG/FxCdjRI82 |
||||
|
jmKSzjEYLshY0yWZcYKmLvO3FAhKTQr0IkM0L/ocDAkpQZQzxwBORDeb09649U2I |
||||
|
MAoDmzLx220JSYqMxNSibO4tzUKtkR16Vn/6X/+vLsWK0HVKLKOU/zMkLozlXnvi |
||||
|
tfOvQYREeStj3eS+At+klA9UofnCH3lKa83yZ2nMS1MLITOLshePOr5BZ6kotXdH |
||||
|
16hBKvQqSHPztof2ZCILXQwfKd3KLPRA/Irz2aBFLKkczDLpBlr0yq8r340YOL1P |
||||
|
5GWMApNrEAGIz8SRszGvRX9xJX3F50hTQqfScwIDAQABAoIBAQCEFaQCunbYQVHt |
||||
|
RJrA0uUlF+ZYSa49SHl6GZMBHGpkbDxppy7ZquHbpPvltDWhk52NVy+e0OBqdrrd |
||||
|
EGyc+U1yktJFdsHRMklq3mJd+eFCoyyFOMoMWKHfuUvmjsxjnhVkzKW/lXPaSOoC |
||||
|
cz+g3Ip0yZZOkfa7W+zAqB1jqoDnDx7CQUmOG/DzFDzQCQJgV/G/EPM0SHT9zew+ |
||||
|
rBvOGOy0n0M7wbJz8JbXn2E/MFqqw0G7KJqT4zFlbzUoopNIcUSfLxX7ihVbX3Dc |
||||
|
WfoCwNsNqHT/kUeH8ouYTwCduPi1UHKcWlM+v2ONW5rCook7i22Zc403AXC4S0/7 |
||||
|
+naXkbeBAoGBAPSZv/wKatakOXcWTODgwOkbLGsDLRw6eb5YK7C7KxddUflPG64Q |
||||
|
kC6apGCC+aMnW21VTyTOtHSvuQi38lieSpJpfeLnn4q0ehZY0D+CEhk+LukpY85r |
||||
|
cN8haGxvP26rVKxZvFH6guAHShJa5ohWj64iaPxPrlCHoOPFHz8VqbaTAoGBANMs |
||||
|
60fmwUO9zkUSipN/Zkrkaf7CR//So77RvlDXsT5SkcrT/hcVzKa2Vxif0YsylG1S |
||||
|
2SJaDvD7+SfLiMddSaP9xQ2473ToaAJhcr7MPWk0of/MGO2n9PDNuEzfd3tWarZi |
||||
|
IYnrQQukOESb3m/Lgz3tBz36ZU3D5Zf3fjzY5AChAoGAPfdxjs2o0WXbdRL+OP5X |
||||
|
gPa0Ywvz8rHRw+ocb3KLcSjgKpPjBE8H5/afbB/iVHYVEHbLTRzc1K7r5oyLZe38 |
||||
|
IGl/Teu2HHKqd1zarSwrn5+ETOeCdHn9p1mUVdw9KrFXCy7UqcQYQd824b2Lp8Ce |
||||
|
N9RZ2onpNFeX5/w5dUbsrucCgYEAyKX/kDvjGjh4iwzI+sisKzDIvbVfr+U2jJLB |
||||
|
4BJxaKQPvsaawNiHsUfDjbQc58PRX+a+RXOIitT/sh4kAjnTRKxU1WsIqu5AFTL+ |
||||
|
UefB2fqWinQko3tYsozlNrWF030Su+SVtXQAQ81vYVEwksyuEOLsZKlMJA2kUzZn |
||||
|
je0PBsECgYBazM6AQPwA8N5baSztrKr8hZkSJrhAdSWIMPT2pCJMe5dso1RfAnFm |
||||
|
iehW7+Mzd8DZTeVm7id73pX6aY4YLjYmbkD9HT/1aZNYP1ESmdvz4++zqKrWEYQw |
||||
|
NbUuyK6tsWfjTOS02clrG6bZYHo/0Vteg1WrBsj5BZQ4LsVhtkvQWA== |
||||
|
-----END RSA PRIVATE KEY----- |
@ -0,0 +1,123 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# --------------------------- |
||||
|
# create scripts |
||||
|
# -------------------------- |
||||
|
if [ "$GIT_TUTOR" ] ; then |
||||
|
|
||||
|
REPO=${GIT_TUTOR##*/} |
||||
|
REPO=${REPO%.git} |
||||
|
|
||||
|
# --------------------------- |
||||
|
# start playground |
||||
|
# -------------------------- |
||||
|
|
||||
|
read -r -d '' VAR <<EOF |
||||
|
#!/bin/bash |
||||
|
|
||||
|
pm2-runtime /home/$USER/crond/playground.config.js |
||||
|
|
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/playground-start.sh |
||||
|
chmod +x /home/$USER/crond/playground-start.sh |
||||
|
|
||||
|
read -r -d '' VAR <<EOF |
||||
|
module.exports = { |
||||
|
"apps": [{ |
||||
|
"name" : "playground-nodejs", |
||||
|
"autorestart" : true, |
||||
|
"watch" : true, |
||||
|
"script" : "/home/$USER/$REPO/swarmlab-app/src/run/app.js", |
||||
|
"args" : "start", |
||||
|
"pid_file" : "/home/$USER/run/pid.pid", |
||||
|
"log_type" : "json", |
||||
|
"log_file" : "/home/$USER/log/logfile", |
||||
|
"error_file" : "/home/$USER/log/errorfile", |
||||
|
"out_file" : "/home/$USER/log/outfile", |
||||
|
"log_date_format": "YYYY-MM-DD HH:mm Z", |
||||
|
"merge_logs" : true, |
||||
|
"exec_mode" : "fork", |
||||
|
"max_restarts": 10, |
||||
|
"max_memory_restart": "500M", |
||||
|
"restart_delay": 1000 |
||||
|
}] |
||||
|
} |
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/playground.config.js |
||||
|
chmod +x /home/$USER/crond/playground.config.js |
||||
|
|
||||
|
# --------------------------- |
||||
|
# sync playground |
||||
|
# -------------------------- |
||||
|
read -r -d '' VAR <<EOF |
||||
|
#!/bin/bash |
||||
|
|
||||
|
cd /home/$USER/project/tutor/$REPO |
||||
|
git fetch origin master |
||||
|
git reset --hard FETCH_HEAD |
||||
|
git clean -df |
||||
|
|
||||
|
|
||||
|
|
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/playground-sync.sh |
||||
|
chmod +x /home/$USER/crond/playground-sync.sh |
||||
|
|
||||
|
# ***************************************************** |
||||
|
# ***************************************************** |
||||
|
# ELSE |
||||
|
# ***************************************************** |
||||
|
# ***************************************************** |
||||
|
|
||||
|
else |
||||
|
|
||||
|
# --------------------------- |
||||
|
# hello world! |
||||
|
# -------------------------- |
||||
|
read -r -d '' VAR <<EOF |
||||
|
#!/bin/bash |
||||
|
|
||||
|
echo "Hello World!" |
||||
|
|
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/playground-start.sh |
||||
|
chmod +x /home/$USER/crond/playground-start.sh |
||||
|
|
||||
|
# --------------------------- |
||||
|
# NO sync playground |
||||
|
# -------------------------- |
||||
|
read -r -d '' VAR <<EOF |
||||
|
#!/bin/bash |
||||
|
|
||||
|
|
||||
|
echo "Hello World!" |
||||
|
|
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/playground-sync.sh |
||||
|
chmod +x /home/$USER/crond/playground-sync.sh |
||||
|
|
||||
|
fi |
||||
|
|
||||
|
read -r -d '' VAR <<EOF |
||||
|
#!/bin/bash |
||||
|
|
||||
|
$NODENAME |
||||
|
$NODEID |
||||
|
$SERVICEID |
||||
|
$SERVICENAME |
||||
|
$TASKID |
||||
|
$TASKNAME |
||||
|
$TASKREPID |
||||
|
|
||||
|
|
||||
|
EOF |
||||
|
echo "$VAR" > /home/$USER/crond/info |
||||
|
|
||||
|
chown -R $USER.$USER /home/$USER |
||||
|
chmod -R 755 /home/$USER |
||||
|
|
||||
|
|
||||
|
/home/$USER/crond/playground-start.sh |
||||
|
/home/$USER/crond/playground-sync.sh |
||||
|
|
||||
|
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf |
@ -0,0 +1,5 @@ |
|||||
|
[program:ttyd] |
||||
|
command=bash -c 'sleep 5 && cd /home/node && sudo -u node ttyd --ssl --ssl-cert /home/node/ssl-ttyd/ca.crt --ssl-key /home/mode/ssl-ttyd/ca.key -c user:%(ENV_PASSWORD)s -p 8088 -u node bash' |
||||
|
stdout_logfile=/var/log/ttyd.log |
||||
|
autorestart=true |
||||
|
|
@ -0,0 +1,46 @@ |
|||||
|
[unix_http_server] |
||||
|
file=/var/run/supervisor.sock ; (the path to the socket file) |
||||
|
;chmod=0700 ; socket file mode (default 0700) |
||||
|
;chown=nobody:nogroup ; socket file uid:gid owner |
||||
|
;username=user ; (default is no username (open server)) |
||||
|
;password=123 ; (default is no password (open server)) |
||||
|
|
||||
|
[inet_http_server] ; inet (TCP) server disabled by default |
||||
|
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface) |
||||
|
;username=user ; (default is no username (open server)) |
||||
|
;password=123 ; (default is no password (open server)) |
||||
|
|
||||
|
[supervisord] |
||||
|
logfile=/dev/null ; (main log file;default $CWD/supervisord.log) |
||||
|
logfile_maxbytes=0 ; (max main logfile bytes b4 rotation;default 50MB) |
||||
|
logfile_backups=0 ; (num of main logfile rotation backups;default 10) |
||||
|
loglevel=info ; (log level;default info; others: debug,warn,trace) |
||||
|
;pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) |
||||
|
nodaemon=true ; (start in foreground if true;default false) |
||||
|
minfds=1024 ; (min. avail startup file descriptors;default 1024) |
||||
|
minprocs=200 ; (min. avail process descriptors;default 200) |
||||
|
;umask=022 ; (process file creation umask;default 022) |
||||
|
;user=chrism ; (default is current user, required if root) |
||||
|
;identifier=supervisor ; (supervisord identifier, default is 'supervisor') |
||||
|
;directory=/tmp ; (default is not to cd during start) |
||||
|
;nocleanup=true ; (don't clean up tempfiles at start;default false) |
||||
|
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP) |
||||
|
;environment=KEY="value" ; (key value pairs to add to environment) |
||||
|
;strip_ansi=false ; (strip ansi escape codes in logs; def. false) |
||||
|
|
||||
|
; the below section must remain in the config file for RPC |
||||
|
; (supervisorctl/web interface) to work, additional interfaces may be |
||||
|
; added by defining them in separate rpcinterface: sections |
||||
|
[rpcinterface:supervisor] |
||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface |
||||
|
|
||||
|
[supervisorctl] |
||||
|
serverurl=unix:///usr/local/var/run/supervisor.sock ; use a unix:// URL for a unix socket |
||||
|
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket |
||||
|
;username=chris ; should be same as http_username if set |
||||
|
;password=123 ; should be same as http_password if set |
||||
|
;prompt=mysupervisor ; cmd line prompt (default "supervisor") |
||||
|
;history_file=~/.sc_history ; use readline history if available |
||||
|
|
||||
|
[include] |
||||
|
files = /etc/supervisor/conf.d/*.conf |
Binary file not shown.
Loading…
Reference in new issue