2018-12-13 20:27:35 +01:00
|
|
|
#!/bin/bash
|
2018-12-14 09:35:48 +01:00
|
|
|
set -euxo pipefail
|
2018-12-13 20:27:35 +01:00
|
|
|
|
|
|
|
|
# This file will store the config env variables needed by the app
|
|
|
|
|
readonly CONF=/build/env.config
|
|
|
|
|
|
2018-12-14 09:35:48 +01:00
|
|
|
# EMAIL_URL can also be set here by injecting another env variable in the template
|
|
|
|
|
# ROOT_URL can also be set at runtime, by querying AWS api or by using ingress annotations in the template for k8s.
|
|
|
|
|
|
2018-12-13 20:27:35 +01:00
|
|
|
cat >"${CONF}" <<'EOF'
|
|
|
|
|
export MONGO_URL=mongodb://{{DATABASE_USER}}:{{DATABASE_PASSWORD}}@{{DATABASE_HOST}}:{{DATABASE_PORT}}/{{DATABASE_NAME}}
|
|
|
|
|
export ROOT_URL=http://localhost
|
|
|
|
|
export PORT=3000
|
2025-10-10 23:46:48 +03:00
|
|
|
|
|
|
|
|
# Docker Compose Secrets Support
|
|
|
|
|
# If secret files exist, read passwords from them instead of environment variables
|
|
|
|
|
if [ -f "/run/secrets/mongo_password" ]; then
|
|
|
|
|
export MONGO_PASSWORD=$(cat /run/secrets/mongo_password)
|
|
|
|
|
export MONGO_URL=mongodb://{{DATABASE_USER}}:${MONGO_PASSWORD}@{{DATABASE_HOST}}:{{DATABASE_PORT}}/{{DATABASE_NAME}}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "/run/secrets/ldap_auth_password" ]; then
|
|
|
|
|
export LDAP_AUTHENTIFICATION_PASSWORD=$(cat /run/secrets/ldap_auth_password)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "/run/secrets/oauth2_secret" ]; then
|
|
|
|
|
export OAUTH2_SECRET=$(cat /run/secrets/oauth2_secret)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "/run/secrets/mail_service_password" ]; then
|
|
|
|
|
export MAIL_SERVICE_PASSWORD=$(cat /run/secrets/mail_service_password)
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -f "/run/secrets/s3_secret" ]; then
|
|
|
|
|
export S3_SECRET=$(cat /run/secrets/s3_secret)
|
|
|
|
|
fi
|
2018-12-13 20:27:35 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
sed -i -e "s/{{DATABASE_USER}}/${DATABASE_USER}/" "${CONF}"
|
|
|
|
|
sed -i -e "s/{{DATABASE_PASSWORD}}/${DATABASE_PASSWORD}/" "${CONF}"
|
|
|
|
|
sed -i -e "s/{{DATABASE_HOST}}/${DATABASE_HOST}/" "${CONF}"
|
|
|
|
|
sed -i -e "s/{{DATABASE_PORT}}/${DATABASE_PORT}/" "${CONF}"
|
|
|
|
|
sed -i -e "s/{{DATABASE_NAME}}/${DATABASE_NAME}/" "${CONF}"
|
|
|
|
|
|