From 4decaf6046c3bd5a2a930ae7ed63780723102e80 Mon Sep 17 00:00:00 2001 From: zeus Date: Wed, 28 Oct 2020 17:28:04 +0200 Subject: [PATCH] Dockerbuild --- Dockerfile.build.iot-example | 1 + Dockerfile.iot-example | 69 ++++++++++++++++++++++++++++++++++++ start-iotserver.sh | 4 +++ start-iotwebclient.sh | 3 ++ stop-iotserver.sh | 4 +++ stop-iotwebclient.sh | 4 +++ supervisord-iot.conf | 13 +++++++ supervisord.conf | 46 ++++++++++++++++++++++++ 8 files changed, 144 insertions(+) create mode 100644 Dockerfile.build.iot-example create mode 100644 Dockerfile.iot-example create mode 100755 start-iotserver.sh create mode 100755 start-iotwebclient.sh create mode 100755 stop-iotserver.sh create mode 100755 stop-iotwebclient.sh create mode 100644 supervisord-iot.conf create mode 100644 supervisord.conf diff --git a/Dockerfile.build.iot-example b/Dockerfile.build.iot-example new file mode 100644 index 0000000..1f50cd2 --- /dev/null +++ b/Dockerfile.build.iot-example @@ -0,0 +1 @@ +docker build -f Dockerfile.iot-example -t hub.swarmlab.io:5443/iot-swarm-example . diff --git a/Dockerfile.iot-example b/Dockerfile.iot-example new file mode 100644 index 0000000..eef3795 --- /dev/null +++ b/Dockerfile.iot-example @@ -0,0 +1,69 @@ +#FROM alpine:3.11 +FROM node:alpine + +LABEL MAINTAINERS="Guillaume Scheibel , Damien DUPORTAL " + +# Installing package required for the runtime +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 + + +COPY iot-swarm-example /home/node/iot-swarm-example/ + +RUN chown -R node.node /home/node \ +&& chmod -R 755 /home/node + +WORKDIR /home/node/iot-swarm-example +VOLUME /home/node/iot-swarm-example + +ENV NODE_PATH=/usr/local/lib/node_modules + +USER node + +RUN cd /home/node/iot-swarm-example/src/browser-client \ + set -uex; \ + npm install \ + npm cache clean --force \ + cd /home/node/iot-swarm-example/src/IoT \ + npm install \ + npm cache clean --force; + + +EXPOSE 8080 8088 8084 3081 + +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/start-iotserver.sh b/start-iotserver.sh new file mode 100755 index 0000000..451d566 --- /dev/null +++ b/start-iotserver.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +#docker run --rm -it -p 8084:8084 -v $PWD/src:/home/node/iot-swarm-example/src hub.swarmlab.io:5443/iot-swarm-example:latest bash -c "node /home/node/iot-swarm-example/src/IoT/llo/iotserver.js" +docker run --rm -it --name iotserver -p 8084:8084 -v $PWD/src:/home/node/iot-swarm-example/src hub.swarmlab.io:5443/iot-swarm-example:latest node /home/node/iot-swarm-example/src/IoT/llo/iotserver.js diff --git a/start-iotwebclient.sh b/start-iotwebclient.sh new file mode 100755 index 0000000..89aa763 --- /dev/null +++ b/start-iotwebclient.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run --rm -it --name iotwebclient -p 8080:8080 -v $PWD/src:/home/node/iot-swarm-example/src hub.swarmlab.io:5443/iot-swarm-example:latest /bin/bash -c "cd /home/node/iot-swarm-example/src/browser-client; npm run serve" diff --git a/stop-iotserver.sh b/stop-iotserver.sh new file mode 100755 index 0000000..fcbe299 --- /dev/null +++ b/stop-iotserver.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker stop iotserver +docker rm iotserver diff --git a/stop-iotwebclient.sh b/stop-iotwebclient.sh new file mode 100755 index 0000000..b17bc67 --- /dev/null +++ b/stop-iotwebclient.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker stop iotwebclient +docker rm iotwebclient diff --git a/supervisord-iot.conf b/supervisord-iot.conf new file mode 100644 index 0000000..dfc14a8 --- /dev/null +++ b/supervisord-iot.conf @@ -0,0 +1,13 @@ +[program:node-app] +environment PATH=/usr/local/sbin +#command=/usr/local/bin/node /usr/src/app/bin/www +command=/usr/local/bin/node /home/node/iot-swarm-example/src/IoT/llo/iotserver.js +user=node +autostart=true +startretries=10 +autorestart=true +priority=1 +stdout_logfile=/dev/fd/1 +stdout_logfile_maxbytes=0 +redirect_stderr=true + diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..332bb82 --- /dev/null +++ b/supervisord.conf @@ -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