EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit 2e7beb82 authored by Mussab Abdalla's avatar Mussab Abdalla
Browse files

attemt to os as secret

parent dec34593
No related branches found
No related tags found
No related merge requests found
#!/bin/bash -e
set -eo pipefail
shopt -s nullglob
SERVICES=${WAIT_SERVICES:=''}
TIMEOUT=${WAIT_TIMEOUT:='15'}
......@@ -8,5 +10,34 @@ if [[ ! -z $SERVICES ]] ; then
wait-for-it -t $TIMEOUT $service
done
fi
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo "Both $var and $fileVar are set (but are exclusive)"
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
echo " the ${var} shall be set to ${val}"
unset "$fileVar"
}
# Loads various settings that are used elsewhere in the script
# This should be called after mysql_check_config, but before any other functions
docker_setup_env() {
# Initialize values that might be stored in a file
file_env 'OS_PASSWORD'
}
docker_setup_env "$@"
eval "/opt/eoxserver/eoxserver-entrypoint.sh $@"
......@@ -130,7 +130,7 @@ services:
- env/emg_obs.env
- env/emg_redis.env
secrets:
- my_secret
- os_password
environment:
INSTANCE_ID: "prism-view-server_registrar"
INSTALL_DIR: "/var/www/pvs/dev/"
......@@ -140,6 +140,7 @@ services:
INIT_SCRIPTS: "/configure.sh /init-db.sh /initialized.sh"
STARTUP_SCRIPTS: "/wait-initialized.sh"
WAIT_SERVICES: "redis:6379 database:5432"
OS_PASSWORD_FILE: /run/secrets/os_password
configs:
- source: init-db
target: /init-db.sh
......@@ -172,5 +173,5 @@ volumes:
networks:
intnet:
secrets:
my_secret:
external: true
os_password:
file: OS_PASSWORD.txt
......@@ -6,7 +6,7 @@ cat $vhr18_obs > ./env/vhr18_obs.env
cat $emg_db > ./env/emg_db.env
cat $emg_django > ./env/emg_django.env
cat $emg_obs > ./env/emg_obs.env
echo "OS_PASSWORD=${OS_PASSWORD}" >> ./OS_PASSWORD.txt
set -o allexport
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment