Very crude dockerization experiment

This commit is contained in:
Tony Garnock-Jones 2018-12-12 17:15:25 +00:00
parent bb250e1471
commit 86a5cee544
8 changed files with 66 additions and 0 deletions

19
docker/Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM alpine:3.8
RUN apk update && apk upgrade
RUN apk add s6
RUN apk add --no-cache nodejs npm --repository http://dl-cdn.alpinelinux.org/alpine/edge/main
RUN npm i -g preserves
ENV NODE_PATH=/usr/lib/node_modules
# RUN apk add --no-cache daemontools --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
RUN apk add dbus avahi avahi-tools
RUN rm -f /etc/avahi/services/*
RUN mkdir -p /run/service
ADD service /run/service
WORKDIR /run/service
CMD ["s6-svscan", "-St1000", "/run/service"]

2
docker/build-docker.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
docker build -t syndicate-js "$(dirname "$0")"

6
docker/cleanup Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
cd "$(dirname "$0")"
sudo rm -rf service/.s6-svscan/control
sudo rm -rf service/.s6-svscan/lock
sudo rm -rf service/*/event/
sudo rm -rf service/*/supervise/

17
docker/docker-broker.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
dir="$(dirname "$0")/.."
case "$dir" in
/*) ;;
*) dir="$(pwd)/${dir}" ;;
esac
networkname=dockerint
if [ -z "$(docker network ls -qf name=${networkname})" ]
then
docker network create --internal ${networkname}
fi
exec docker run -it --rm \
--network ${networkname} \
-v "${dir}":/data \
syndicate-js

View file

@ -0,0 +1,13 @@
#!/bin/sh
kill -TERM -1
while true
do
running="$(ps a)"
if [ "$(echo "${running}" | wc -l)" = "3" ]
then
break
else
echo Waiting for services to shut down...
sleep 1
fi
done

View file

@ -0,0 +1,3 @@
#!/bin/sh
s6-svwait ../dbus-daemon
exec avahi-daemon

2
docker/service/dbus-daemon/run Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
exec dbus-daemon --system --nofork

View file

@ -0,0 +1,4 @@
#!/bin/sh
s6-svwait ../avahi-daemon
cd /data/packages/broker
exec node lib/index.js