parent
35e577b866
commit
b691b631e9
@ -0,0 +1,17 @@ |
||||
#!/bin/sh |
||||
# A script that supervises a program. The program is restarted TIMEOUT second after it exits. |
||||
# SIGHUP restarts the program |
||||
# SIGTERM and SIGINT stops the program |
||||
|
||||
TIMEOUT=1 |
||||
|
||||
running=1 |
||||
trap 'kill -TERM $! 2>/dev/null' HUP |
||||
trap 'running=0; kill -TERM $! 2>/dev/null' TERM INT |
||||
trap 'running=0; kill -KILL $! 2>/dev/null' EXIT |
||||
|
||||
while [ "$running" = 1 ]; do |
||||
"$@" & |
||||
wait |
||||
sleep "$TIMEOUT" |
||||
done |
@ -0,0 +1,44 @@ |
||||
version: "3.6" |
||||
|
||||
x-common: &common |
||||
image: python:3.7-buster |
||||
volumes: |
||||
- .:$PWD |
||||
environment: |
||||
FLASK_APP: ceod.api |
||||
FLASK_ENV: development |
||||
working_dir: $PWD |
||||
entrypoint: |
||||
- ./docker-entrypoint.sh |
||||
|
||||
services: |
||||
auth1: |
||||
<<: *common |
||||
image: debian:buster |
||||
hostname: auth0 |
||||
command: auth1 |
||||
|
||||
coffee: |
||||
<<: *common |
||||
command: coffee |
||||
hostname: coffee |
||||
depends_on: |
||||
- auth1 |
||||
|
||||
mail: |
||||
<<: *common |
||||
command: mail |
||||
hostname: mail |
||||
depends_on: |
||||
- auth1 |
||||
|
||||
phosphoric-acid: |
||||
<<: *common |
||||
command: phosphoric-acid |
||||
hostname: phosphoric-acid |
||||
depends_on: |
||||
- auth1 |
||||
- coffee |
||||
- mail |
||||
|
||||
# vim: expandtab sw=2 ts=2 |
@ -0,0 +1,10 @@ |
||||
#!/bin/sh -e |
||||
host="$1" |
||||
[ -x ".drone/$host-setup.sh" ] && "./.drone/$host-setup.sh" |
||||
|
||||
if [ "$host" = auth1 ]; then |
||||
exec sleep infinity |
||||
else |
||||
python3 -m pip install -r requirements.txt -r dev-requirements.txt |
||||
exec ./.drone/supervise.sh flask run -h 0.0.0.0 -p 9987 |
||||
fi |
@ -1,41 +0,0 @@ |
||||
#!/bin/bash |
||||
|
||||
set -x |
||||
|
||||
case $1 in |
||||
up) |
||||
if ! [ -d venv ]; then |
||||
docker run --rm -v "$PWD:$PWD" -w "$PWD" python:3.7-buster \ |
||||
sh -c "python -m venv venv && . venv/bin/activate && pip install -r dev-requirements.txt && pip install -r requirements.txt" |
||||
fi |
||||
docker network create ceod |
||||
for host in auth1 coffee mail phosphoric-acid; do |
||||
if [ $host = auth1 ]; then |
||||
image=debian:buster |
||||
else |
||||
image=python:3.7-buster |
||||
fi |
||||
docker run \ |
||||
--detach \ |
||||
--name $host \ |
||||
--hostname $host \ |
||||
--network ceod \ |
||||
--volume "$PWD:$PWD" \ |
||||
--workdir "$PWD" \ |
||||
--env FLASK_APP=ceod.api \ |
||||
--env FLASK_ENV=development \ |
||||
$image .drone/$host-setup.sh |
||||
done |
||||
;; |
||||
down) |
||||
for host in auth1 coffee mail phosphoric-acid; do |
||||
docker kill $host |
||||
docker rm $host |
||||
done |
||||
docker network rm ceod |
||||
;; |
||||
*) |
||||
echo 'Usage: docker.sh <up|down>' >&2 |
||||
exit 1 |
||||
;; |
||||
esac |
Loading…
Reference in new issue