From 56a44f8db361c879f1080f7321e4226a16e7d266 Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Thu, 2 Jul 2020 11:26:32 +0200 Subject: [PATCH] Add 'self' stack This commit adds a new stack 'self' that for now just redirects to the repository. --- distillery/lib/10_config.sh | 1 + distillery/provision.sh | 2 +- .../environment => compose/self/.env.sample} | 11 +++++----- .../resources/compose/self/docker-compose.yml | 22 +++++++++++++++++++ .../resources/compose/web/docker-compose.yml | 2 ++ .../resources/templates/docker-env/runtime | 6 +++++ .../resources/templates/docker-env/self | 6 +++++ distillery/resources/templates/docker-env/web | 1 + distillery/system_install.sh | 22 +++++++++++++++++++ distillery/system_update.sh | 3 +++ 10 files changed, 69 insertions(+), 7 deletions(-) rename distillery/resources/{templates/runtime-config/environment => compose/self/.env.sample} (57%) create mode 100644 distillery/resources/compose/self/docker-compose.yml create mode 100644 distillery/resources/templates/docker-env/runtime create mode 100644 distillery/resources/templates/docker-env/self create mode 100644 distillery/resources/templates/docker-env/web diff --git a/distillery/lib/10_config.sh b/distillery/lib/10_config.sh index e343590..55a11be 100644 --- a/distillery/lib/10_config.sh +++ b/distillery/lib/10_config.sh @@ -152,6 +152,7 @@ fi # paths to composer things DEPLOY_WEB_DIR="$DEPLOY_ROOT/core/web" +DEPLOY_SELF_DIR="$DEPLOY_ROOT/core/self" DEPLOY_TRIPLESTORE_DIR="$DEPLOY_ROOT/core/triplestore" DEPLOY_SQL_DIR="$DEPLOY_ROOT/core/sql" DEPLOY_INSTANCES_DIR="$DEPLOY_ROOT/instances" diff --git a/distillery/provision.sh b/distillery/provision.sh index 67a61ca..f6b0abb 100755 --- a/distillery/provision.sh +++ b/distillery/provision.sh @@ -80,7 +80,7 @@ sql_bookkeep_insert \ "\"${SLUG}\",\"${INSTANCE_BASE_DIR}\",\"${MYSQL_DATABASE}\",\"${MYSQL_USER}\",\"${MYSQL_PASSWORD}\",\"${GRAPHDB_REPO}\",\"${GRAPHDB_USER}\",\"${GRAPHDB_PASSWORD}\"" log_info " => Writing configuration file" -load_template "runtime-config/environment" \ +load_template "docker-env/runtime" \ "REAL_PATH" "${INSTANCE_DATA_DIR}" \ "VIRTUAL_HOST" "${INSTANCE_DOMAIN}" \ "LETSENCRYPT_HOST" "${LETSENCRYPT_HOST}" \ diff --git a/distillery/resources/templates/runtime-config/environment b/distillery/resources/compose/self/.env.sample similarity index 57% rename from distillery/resources/templates/runtime-config/environment rename to distillery/resources/compose/self/.env.sample index cdddb42..d7eba20 100644 --- a/distillery/resources/templates/runtime-config/environment +++ b/distillery/resources/compose/self/.env.sample @@ -1,17 +1,16 @@ ####################### # Meta Settings ####################### - -# Real path for volumes to be stored -REAL_PATH=${REAL_PATH} +# The target path to redirect to +TARGET=https://gitlab.cs.fau.de/AGFD/wisski-distillery ####################### ### Web Server settings ####################### # the hostname for the website -VIRTUAL_HOST=${VIRTUAL_HOST} +VIRTUAL_HOST=example.com # optional letsencrypt support # when blank, ignore -LETSENCRYPT_HOST=${LETSENCRYPT_HOST} -LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} +LETSENCRYPT_HOST= +LETSENCRYPT_EMAIL= diff --git a/distillery/resources/compose/self/docker-compose.yml b/distillery/resources/compose/self/docker-compose.yml new file mode 100644 index 0000000..501e02b --- /dev/null +++ b/distillery/resources/compose/self/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.7" + +services: + tr: + image: tkw01536/tr + restart: always + environment: + # port and hostname for this image to use + VIRTUAL_HOST: ${VIRTUAL_HOST} + VIRTUAL_PORT: 8080 + + # optional letsencrypt email + LETSENCRYPT_HOST: ${LETSENCRYPT_HOST} + LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} + + # where to redirect to + TARGET: ${TARGET} + +networks: + default: + external: + name: distillery diff --git a/distillery/resources/compose/web/docker-compose.yml b/distillery/resources/compose/web/docker-compose.yml index 23b24a4..b4bb7ce 100644 --- a/distillery/resources/compose/web/docker-compose.yml +++ b/distillery/resources/compose/web/docker-compose.yml @@ -3,6 +3,8 @@ version: "3.7" services: nginx-proxy: image: nginxproxy/nginx-proxy:alpine + environment: + - DEFAULT_HOST=${DEFAULT_HOST} ports: - "80:80" - "443:443" diff --git a/distillery/resources/templates/docker-env/runtime b/distillery/resources/templates/docker-env/runtime new file mode 100644 index 0000000..d137b6b --- /dev/null +++ b/distillery/resources/templates/docker-env/runtime @@ -0,0 +1,6 @@ +REAL_PATH=${REAL_PATH} + +VIRTUAL_HOST=${VIRTUAL_HOST} + +LETSENCRYPT_HOST=${LETSENCRYPT_HOST} +LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} diff --git a/distillery/resources/templates/docker-env/self b/distillery/resources/templates/docker-env/self new file mode 100644 index 0000000..9c188b5 --- /dev/null +++ b/distillery/resources/templates/docker-env/self @@ -0,0 +1,6 @@ +VIRTUAL_HOST=${VIRTUAL_HOST} + +LETSENCRYPT_HOST=${LETSENCRYPT_HOST} +LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} + +TARGET=https://gitlab.cs.fau.de/AGFD/wisski-distillery \ No newline at end of file diff --git a/distillery/resources/templates/docker-env/web b/distillery/resources/templates/docker-env/web new file mode 100644 index 0000000..11938e2 --- /dev/null +++ b/distillery/resources/templates/docker-env/web @@ -0,0 +1 @@ +DEFAULT_HOST=${DEFAULT_HOST} \ No newline at end of file diff --git a/distillery/system_install.sh b/distillery/system_install.sh index 12f98d1..63a50b1 100755 --- a/distillery/system_install.sh +++ b/distillery/system_install.sh @@ -48,6 +48,7 @@ pip3 install --upgrade docker-compose log_info "=> Creating docker-compose directories" mkdir -p "$DEPLOY_INSTANCES_DIR" mkdir -p "$DEPLOY_WEB_DIR" +mkdir -p "$DEPLOY_SELF_DIR" mkdir -p "$DEPLOY_TRIPLESTORE_DIR" mkdir -p "$DEPLOY_SQL_DIR" @@ -57,6 +58,27 @@ docker network create distillery || true log_info "=> Creating 'docker-compose' files for the 'web'. " install_resource_dir "compose/web" "$DEPLOY_WEB_DIR" +log_info " => Writing 'web' configuration file" +load_template "docker-env/web" \ + "DEFAULT_HOST" "${DEFAULT_DOMAIN}" \ + > "$DEPLOY_WEB_DIR/.env" + +log_info "=> Creating 'docker-compose' files for the 'self'. " +install_resource_dir "compose/self" "$DEPLOY_SELF_DIR" + +# setup the lesencrypt host for the default domain +if [ -n "$LETSENCRYPT_HOST" ]; then + LETSENCRYPT_HOST="$DEFAULT_DOMAIN" +fi; + +log_info " => Writing 'self' configuration file" +load_template "docker-env/self" \ + "VIRTUAL_HOST" "${DEFAULT_DOMAIN}" \ + "LETSENCRYPT_HOST" "${LETSENCRYPT_HOST}" \ + "LETSENCRYPT_EMAIL" "${LETSENCRYPT_EMAIL}" \ + > "$DEPLOY_SELF_DIR/.env" + + # copy over the directory log_info "=> Creating 'docker-compose' files for the 'triplestore'. " install_resource_dir "compose/triplestore" "$DEPLOY_TRIPLESTORE_DIR" diff --git a/distillery/system_update.sh b/distillery/system_update.sh index 35300ca..cdf24cd 100755 --- a/distillery/system_update.sh +++ b/distillery/system_update.sh @@ -17,6 +17,9 @@ function update_stack() { log_info "=> Rebuilding and restarting 'web' stack" update_stack "$DEPLOY_WEB_DIR" +log_info "=> Rebuilding and restarting 'self' stack" +update_stack "$DEPLOY_SELF_DIR" + # build and start the triplestore log_info "=> Rebuilding and restarting 'triplestore' stack" update_stack "$DEPLOY_TRIPLESTORE_DIR"