Browse Source

Dockerbuild

master
zeus 4 years ago
parent
commit
4decaf6046
  1. 1
      Dockerfile.build.iot-example
  2. 69
      Dockerfile.iot-example
  3. 4
      start-iotserver.sh
  4. 3
      start-iotwebclient.sh
  5. 4
      stop-iotserver.sh
  6. 4
      stop-iotwebclient.sh
  7. 13
      supervisord-iot.conf
  8. 46
      supervisord.conf

1
Dockerfile.build.iot-example

@ -0,0 +1 @@
docker build -f Dockerfile.iot-example -t hub.swarmlab.io:5443/iot-swarm-example .

69
Dockerfile.iot-example

@ -0,0 +1,69 @@
#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
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"]

4
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

3
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"

4
stop-iotserver.sh

@ -0,0 +1,4 @@
#!/bin/bash
docker stop iotserver
docker rm iotserver

4
stop-iotwebclient.sh

@ -0,0 +1,4 @@
#!/bin/bash
docker stop iotwebclient
docker rm iotwebclient

13
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

46
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
Loading…
Cancel
Save