Closed MdreW closed 5 months ago
The mixed approach was probably a solution to reference an already defined variable in the docker-compose.yaml
file, e.g.:
This is a workaround since docker compose files can't use an environment variable defined in itself (see https://stackoverflow.com/a/63443704).
The possible solution is to use the suggested approach with a default value in the environment section of the docker compose file and let the user override them in the .env
file.
A little add:
version: '3'
services:
satosa-nginx:
environments:
NGINX_HOSTNAME: "${HOSTNAME:-localhost}"
satosa-mongo:
environments:
MONGODB_PASSWORD: "${MONGO_DBPASSWORD:-12345678}"
MONGODB_USERNAME: "${MONGO_DBUSER:-satosa}"
satosa-saml2spid:
environment:
SATOSA_HOSTNAME: "${HOSTNAME:-localhost}"
SATOSA_BASE: "https://$SATOSA_HOSTNAME"
SATOSA_BASE_STATIC: https://$SATOSA_HOSTNAME/static
SATOSA_DISCO_SRV: https://$SATOSA_HOSTNAME/static/disco.html
SATOSA_UNKNOW_ERROR_REDIRECT_PAGE: https://$SATOSA_HOSTNAME/static/error_page.html
MONGODB_PASSWORD: "${MONGO_DBPASSWORD:-12345678}"
MONGODB_USERNAME: "${MONGO_DBUSER:-satosa}"
docker-compose call some configuration from .env file and some other are called locally. This process require more time to find the configuration. If we want use .env file I propose to set all the configuration with an environment with a default. Example