Homogeneous environment for dockerfile and .env
MdreW opened this issue · 2 comments
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
environment:
MONGO_INITDB_DATABASE: ${MONGO_DB:-oidcop}
MONGO_INITDB_ROOT_USERNAME: "${MONGO_DBUSER:-satosa}"
MONGO_INITDB_ROOT_PASSWORD: "${MONGO_DBPASSWORD:-password}"
The mixed approach was probably a solution to reference an already defined variable in the docker-compose.yaml
file, e.g.:
Satosa-Saml2Spid/Docker-compose/docker-compose.yml
Lines 68 to 71 in 22d05ba
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}"