diff --git a/config.py b/config.py index 48eca6b2..ca4fb620 100644 --- a/config.py +++ b/config.py @@ -20,7 +20,7 @@ class Config: ''' ### Opaque ### ''' NOPAQUE_ADMIN = os.environ.get('NOPAQUE_ADMIN') - NOPAQUE_STORAGE = '/mnt/nopaque' + NOPAQUE_STORAGE = os.environ.get('NOPAQUE_STORAGE') @staticmethod def init_app(app): diff --git a/dind_swarm.yml b/dind_swarm.yml deleted file mode 100644 index 8e3e58ed..00000000 --- a/dind_swarm.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: '3' - -services: - storage: - command: - - "-p" - - "-s" - - "storage.nopaque;/srv/nopaque/storage;no;no;no;nopaque" - - "-u" - - "nopaque;nopaque" - image: dperson/samba:latest - ports: - - "445:445" - volumes: - - "/srv/nopaque/storage:/srv/nopaque/storage" - worker: - image: docker:dind - ports: - - "2375" - privileged: true - volumes: - - "/mnt/nopaque:/mnt/nopaque" - viz: - image: dockersamples/visualizer:latest - labels: - - "traefik.enable=true" - - "traefik.http.routers.viz.rule=Host(`viz.localhost`)" - - "traefik.http.routers.viz.entrypoints=web" - volumes: - - "/var/run/docker.sock:/var/run/docker.sock" diff --git a/dind_swarm_setup.sh b/dind_swarm_setup.sh deleted file mode 100755 index 704c408d..00000000 --- a/dind_swarm_setup.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -ECHO_COLOR="\033[0;34m" -ECHO_COLOR_END="\033[0m" -SWARM_MANAGER_IP="" -SWARM_WORKER_NUMBER=4 - -if [ -z ${SWARM_MANAGER_IP} ]; then - # See https://stackoverflow.com/a/25851186 - SWARM_MANAGER_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') -fi -echo -e "${ECHO_COLOR}Leave possible swarm and down all services...${ECHO_COLOR_END}" -docker swarm leave --force -docker-compose --file dind_swarm.yml down - -echo -e "${ECHO_COLOR}Start storage container...${ECHO_COLOR_END}" -docker-compose --file dind_swarm.yml up --detach storage -sleep 3 - -echo -e "${ECHO_COLOR}Mount network storage to host system...${ECHO_COLOR_END}" -if [ ! -d "/mnt/nopaque" ]; then - sudo mkdir -p /mnt/nopaque -fi -if mountpoint -q /mnt/nopaque; then - sudo umount --force /mnt/nopaque -fi -sudo mount --types cifs --options gid=${USER},password=nopaque,uid=${USER},user=nopaque,vers=3.0 //localhost/storage.nopaque /mnt/nopaque - -echo -e "${ECHO_COLOR}Start worker service(s)...${ECHO_COLOR_END}" -docker-compose --file dind_swarm.yml up --detach --scale worker=${SWARM_WORKER_NUMBER} worker viz -sleep 7 - -echo -e "${ECHO_COLOR}Init Docker swarm...${ECHO_COLOR_END}" -docker swarm init --advertise-addr ${SWARM_MANAGER_IP} > /dev/null - -echo -e "${ECHO_COLOR}Add workers to swarm...${ECHO_COLOR_END}" -SWARM_WORKER_TOKEN=$(docker swarm join-token -q worker) -for i in $(seq 1 ${SWARM_WORKER_NUMBER}); do - echo -n "[worker_${i}]: " - docker-compose --file dind_swarm.yml exec --index=${i} worker docker swarm join --token ${SWARM_WORKER_TOKEN} ${SWARM_MANAGER_IP}:2377 -done diff --git a/docker-compose.yml b/docker-compose.yml index 1f08a71b..8fbb5333 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,11 @@ -version: '3' +version: '3.5' + +networks: + reverse-proxy: + external: + name: reverse-proxy services: - reverse-proxy: - image: traefik:2.2 - command: - - "--log.level=DEBUG" - - "--providers.docker=true" - - "--providers.docker.exposedbydefault=false" - - "--entrypoints.web.address=:80" - ports: - - "80:80" - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" web: depends_on: - db @@ -19,11 +13,15 @@ services: env_file: nopaque.env image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:development labels: + - "traefik.docker.network=reverse-proxy" - "traefik.enable=true" - - "traefik.http.routers.nopaque.rule=Host(`nopaque.localhost`)" - - "traefik.http.routers.nopaque.entrypoints=web" + - "traefik.http.routers.proxy.rule=Host(`nopaque.localhost`)" + - "traefik.http.routers.proxy.entrypoints=web" + networks: + - default + - reverse-proxy volumes: - - "/mnt/nopaque:/mnt/nopaque" + - "/mnt/dind_swarm/nopaque:/mnt/nopaque" - "./app:/home/nopaque/app" - "./logs:/home/nopaque/logs" - "./migrations:/home/nopaque/migrations" @@ -40,7 +38,7 @@ services: - "host.docker.internal:172.17.0.1" image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest volumes: - - "/mnt/nopaque:/mnt/nopaque" + - "/mnt/dind_swarm/nopaque:/mnt/nopaque" - "./logs:/home/nopaqued/logs" - "../opaque_daemon/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh" - "../opaque_daemon/nopaqued.py:/home/nopaqued/nopaqued.py" diff --git a/nopaque.env.tpl b/nopaque.env.tpl index aa8a6cdc..101fbf64 100644 --- a/nopaque.env.tpl +++ b/nopaque.env.tpl @@ -26,3 +26,5 @@ MAIL_DEFAULT_SENDER= ### nopaque ### NOPAQUE_ADMIN= +NOPAQUE_HOST_STORAGE= +NOPAQUE_STORAGE=