From ed2f2ad590577cababe7e10f2f1cd6daa4ad09ec Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Dec 2021 13:48:28 +0100 Subject: [PATCH] Added files for running a gbn project --- .gitignore | 10 ++++ convenience/bridgehead@.service | 15 ++--- convenience/traefik.service | 19 ------ gbn/docker-compose.yml | 4 +- gbn/gbn.env.dev | 2 + install-bridgehead.sh | 79 ++++++++++++------------ prerequisites.sh | 103 +++++++++++++++++--------------- site.dev.conf | 59 ++++++++++++++++++ 8 files changed, 170 insertions(+), 121 deletions(-) create mode 100644 .gitignore delete mode 100644 convenience/traefik.service create mode 100644 gbn/gbn.env.dev mode change 100644 => 100755 install-bridgehead.sh mode change 100644 => 100755 prerequisites.sh create mode 100644 site.dev.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1362ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +##Ignore site configuration +.gitsubmodules +site-config + +## Ignore site configuration +config/**/* +!config/**/*.default +docker-compose.override.yml +site-specific.conf + diff --git a/convenience/bridgehead@.service b/convenience/bridgehead@.service index dd86c45..b4b5c9f 100644 --- a/convenience/bridgehead@.service +++ b/convenience/bridgehead@.service @@ -1,23 +1,16 @@ [Unit] Description=Bridgehead (%i) Service -Requires=traefik.service -After=traefik.service [Service] Restart=always RestartSec=30 -WorkingDirectory=/srv/docker/bridgehead +WorkingDirectory=/srv/docker/bridgehead/%i -ExecStartPre=/usr/local/bin/docker-compose --env-file site-config/%i.env down -ExecStartPre=/usr/local/bin/docker-compose --env-file site-config/%i.env rm -ExecStartPre=CONNECTOR_POSTGRES_PASSWORD=%i_CONNECTOR_POSTGRES_PASSWORD -ExecStartPre=export CONNECTOR_POSTGRES_PASSWORD -ExecStart=/usr/local/bin/docker-compose --env-file site-config/%i.env up -ExecStart=CONNECTOR_POSTGRES_PASSWORD= -ExecStart=export CONNECTOR_POSTGRES_PASSWORD +ExecStartPre=/usr/local/bin/docker-compose --env-file ../site-config/%i.env down +ExecStart=/usr/local/bin/docker-compose --env-file ../site-config/%i.env up -ExecStop=/usr/local/bin/docker-compose --env-file site-config/%i.env down +ExecStop=/usr/local/bin/docker-compose --env-file ../site-config/%i.env down [Install] WantedBy=multi-user.target diff --git a/convenience/traefik.service b/convenience/traefik.service deleted file mode 100644 index 8c52ee3..0000000 --- a/convenience/traefik.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=Traefik Service -Requires=docker.service -After=docker.service - -[Service] -Restart=always -RestartSec=30 - -WorkingDirectory=/srv/docker/bridgehead - -ExecStartPre=/usr/local/bin/docker-compose --env-file site-config/start.env down -ExecStartPre=/usr/local/bin/docker-compose --env-file site-config/start.env rm -ExecStart=/usr/local/bin/docker-compose --env-file site-config/start.env up - -ExecStop=/usr/local/bin/docker-compose --env-file site-config/start.env down - -[Install] -WantedBy=multi-user.target diff --git a/gbn/docker-compose.yml b/gbn/docker-compose.yml index abba8de..dbcf044 100644 --- a/gbn/docker-compose.yml +++ b/gbn/docker-compose.yml @@ -22,7 +22,7 @@ services: POSTGRES_HOST: "connector-db" POSTGRES_DB: "samply.connector" POSTGRES_USER: "samply" - POSTGRES_PASS: "samply" + POSTGRES_PASS: ${GBN_CONNECTOR_POSTGRES_PASS} STORE_URL: "http://store:8080/fhir" QUERY_LANGUAGE: "CQL" MDR_URL: "https://mdr.germanbiobanknode.de/v3/api/mdr" @@ -37,7 +37,7 @@ services: connector-db: container_name: "connector-db" - image: "postgres:9.6" + image: "postgres:10.17" environment: POSTGRES_USER: "samply" POSTGRES_PASSWORD: "samply" diff --git a/gbn/gbn.env.dev b/gbn/gbn.env.dev new file mode 100644 index 0000000..767700c --- /dev/null +++ b/gbn/gbn.env.dev @@ -0,0 +1,2 @@ +GBN_CONNECTOR_POSTGRES_PASS=samply + diff --git a/install-bridgehead.sh b/install-bridgehead.sh old mode 100644 new mode 100755 index 2ada9c6..1bbd7fe --- a/install-bridgehead.sh +++ b/install-bridgehead.sh @@ -1,40 +1,39 @@ -#!/bin/bash -### Note: Currently not complete, needs some features before useable for production - -./prerequisites.sh -source site.conf - -echo "Installing bridgehead" - -cd /etc/systemd/system/ - -echo "Installing bridgehead\@.service in systemd ..." -sudo cp /srv/docker/bridgehead/convenience/bridgehead\@.service ./ -echo "Installing bridgehead\@.update.service in systemd ..." -sudo cp /srv/docker/bridgehead/convenience/bridgehead-update\@.service ./ -sudo cp /srv/docker/bridgehead/convenience/bridgehead-update\@.timer ./ - -echo "Loading the bridgehead and traefik service definitions in systemd" -sudo systemctl daemon-reload - - -echo "Starting Project ${project} " - if [ ! -f "/etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf" ]; then - echo "Can't find local configuration file for bridgehead@${project} service. Please ensure that the file /etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf exists" - continue - fi - - sudo systemctl is-active --quiet bridgehead@"${project}" - if [ ! $? -eq 0 ]; then - echo "Starting bridgehead@${project} service ..." - sudo systemctl start bridgehead@"${project}" - echo "Enabling autostart of bridgehead@${project}.service" - sudo systemctl enable bridgehead@"${project}" - echo "Enabling nightly updates for bridgehead@${project}.service ..." - sudo systemctl enable --now bridgehead-update@"${project}".timer - fi -done - -# Switch back to execution directory; -cd - -# TODO: Configuration of the different modules +#!/bin/bash +### Note: Currently not complete, needs some features before useable for production + +./prerequisites.sh +source site.conf + +echo "Installing bridgehead" + +cd /etc/systemd/system/ + +echo "Installing bridgehead\@.service in systemd ..." +sudo cp /srv/docker/bridgehead/convenience/bridgehead\@.service ./ +echo "Installing bridgehead\@.update.service in systemd ..." +sudo cp /srv/docker/bridgehead/convenience/bridgehead-update\@.service ./ +sudo cp /srv/docker/bridgehead/convenience/bridgehead-update\@.timer ./ + +echo "Loading the bridgehead and traefik service definitions in systemd" +sudo systemctl daemon-reload + + +echo "Starting Project ${project} " + if [ ! -f "/etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf" ]; then + echo "Can't find local configuration file for bridgehead@${project} service. Please ensure that the file /etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf exists" + continue + fi + + sudo systemctl is-active --quiet bridgehead@"${project}" + if [ ! $? -eq 0 ]; then + echo "Starting bridgehead@${project} service ..." + sudo systemctl start bridgehead@"${project}" + echo "Enabling autostart of bridgehead@${project}.service" + sudo systemctl enable bridgehead@"${project}" + echo "Enabling nightly updates for bridgehead@${project}.service ..." + sudo systemctl enable --now bridgehead-update@"${project}".timer + fi + +# Switch back to execution directory; +cd - +# TODO: Configuration of the different modules diff --git a/prerequisites.sh b/prerequisites.sh old mode 100644 new mode 100755 index 91d8a50..438df45 --- a/prerequisites.sh +++ b/prerequisites.sh @@ -1,49 +1,54 @@ -#!/bin/bash - - -## Check if user is a su -echo "Welcome to the starting a bridgehead. We will get your instance up and running in no time" -echo "First we will check if all prerequisites are met ..." -prerequisites="git docker docker-compose" -for prerequisite in $prerequisites; do - $prerequisite --version 2>&1 - is_available=$? - if [ $is_available -gt 0 ]; then - log "ERROR" "Prerequisite not fulfilled - $prerequisite is not available!" - exit 79 - fi - # TODO: Check for specific version -done -echo "All prerequisites are installed. Now we can download the bridgehead from https://code.mitro.dkfz.de/scm/docker/c4.bk.docker.git." - -#check if site.conf is created -if [ ! -f site.conf ]; then - echo "Please create your specific site.conf file from the site.dev.conf" - exit -fi - -#Load site specific variables -source site.conf - -if [ -z "$site_name" ]; then - echo "Site name is empty,please enter site name:" - read -r site_name - site_name_lowercase=$(echo "$site_name" | tr '[:upper:]' '[:lower:]') -fi - -## Download submodule -if [ ! -d "site-config" ]; then - echo "Please set up the site-config folder. Instruction are in the readme." - exit -else - echo "Site configuration is already loaded" -fi - -#Check if a project is selected -if [ -z "$project" ]; then - echo "No project selected! Please add a Project in your local site.conf." - exit -fi - -# Check for each project -echo "All prerequisites meet! All systems are ready to go!" +#!/bin/bash + + +## Check if user is a su +echo "Welcome to the starting a bridgehead. We will get your instance up and running in no time" +echo "First we will check if all prerequisites are met ..." +prerequisites="git docker docker-compose" +for prerequisite in $prerequisites; do + $prerequisite --version 2>&1 + is_available=$? + if [ $is_available -gt 0 ]; then + log "ERROR" "Prerequisite not fulfilled - $prerequisite is not available!" + exit 79 + fi + # TODO: Check for specific version +done + +echo "Checking site.conf" + +#check if site.conf is created +if [ ! -f site.conf ]; then + echo "Please create your specific site.conf file from the site.dev.conf" + exit +fi + +#Load site specific variables +source site.conf + +if [ -z "$site_name" ]; then + echo "Please set site_name" +fi + +echo "Checking site-config module" + +## Download submodule +if [ ! -d "site-config" ]; then + echo "Please set up the site-config folder. Instruction are in the readme." + exit +else + echo "Site configuration is already loaded" +fi + +#Check if a project is selected +if [ -z "$project" ]; then + echo "No project selected! Please add a Project in your local site.conf." + exit +fi + +#check if project env is present +if [ -d "site-config/${project}.env" ]; then + echo "Please copy the tempalte from ${project} and put it in the site-config folder" +fi + +echo "All prerequisites meet! All systems are ready to go!" diff --git a/site.dev.conf b/site.dev.conf new file mode 100644 index 0000000..216e367 --- /dev/null +++ b/site.dev.conf @@ -0,0 +1,59 @@ +#!/bin/bash +### This is the configuration file for secrets, only your site should know +### Because the deployment via systemd is not possible in the current wsl environment, +### developers need to export the necessary variables. +### You can copy this file to site-specific.conf and run source site-specific.conf. +### After this docker-compose up should use the environment variables defined in this file. + +### Connector configuration +## The password the for your connector database +export dktk_CONNECTOR_POSTGRES_PASSWORD= +export c4_CONNECTOR_POSTGRES_PASSWORD= +export gbn_CONNECTOR_POSTGRES_PASSWORD= + +### Local Datamanagenment configuration if necessary +## Supply this, if you use samplystore +# export LDM_DATABASE_PASSWORD=this-should-only-be-used-by-developers-ldm-database-password; + +### ID-Management configuration +## provided by DKFZ with cooperation in Mainz +export CCP_PATIENTLISTE_APIKEY= +## provided by DKFZ with cooperation in Frankfurt +export CCP_CONTROLLNUMBERGENERATOR_APIKEY= +export LOCAL_IDMANAGER_LDM_APIKEY= +## Additional new ID-Manager Configuration +export LOCAL_IDMANAGER_MAINZELLISTE_APIKEY= +export LOCAL_IDMANAGER_CONNECTOR_APIKEY= +export LOCAL_PATIENTLIST_DBPASS= + +export dktk_CCP_OIDC_CLIENT_SECRET= +export c4_CCP_OIDC_CLIENT_SECRET= +### Mail Server username and password +# export MAIL_USER= +# export MAIL_PASSWORD= + +### Monitoring +## by default, the bridgehead will report it's state to DKFZ monitoring. Change here to opt-out. +# export MONITOR_OPTOUT=true + +### nNGM Configuration, only necessary if your site takes part in nNGM +## The cts login data, that healex provided you +# export NNGM_CTS_USER= +# export NNGM_CTS_PASSWORD= +## The idmanagement authentication data, that is provided by dkfz dataprotection office +# export NNGM_MAGICPL_APIKEY= +# export NNGM_MAINZELLISTE_APIKEY= + +### Workaround for local developers network environment +## Note: MSYS_NO_PATHCONV is needed, because git bash and msys2 will otherwise convert /etc/hosts to a windows path +#export HOSTIP=$(MSYS_NO_PATHCONV=1 docker run --rm --add-host=host.docker.internal:host-gateway ubuntu cat /etc/hosts | grep 'host.docker.internal' | awk '{print $1}'); +#export HOST=$(hostname) + +export HOSTIP= +export HOST= + +export site_name= +### Write the Project you want to start with the brigdehead +##Exmaple project=gbn +project= +