Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homogeneous environment for dockerfile and .env #112

Closed
MdreW opened this issue Jan 30, 2024 · 2 comments · Fixed by #121
Closed

Homogeneous environment for dockerfile and .env #112

MdreW opened this issue Jan 30, 2024 · 2 comments · Fixed by #121
Assignees
Labels
enhancement New feature or request question Further information is requested
Milestone

Comments

@MdreW
Copy link
Collaborator

MdreW commented Jan 30, 2024

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}"
@MdreW MdreW added the enhancement New feature or request label Jan 30, 2024
@davidelongo-ey davidelongo-ey added this to the 2.0 milestone Feb 5, 2024
@davidelongo-ey davidelongo-ey added the question Further information is requested label Feb 5, 2024
@salvatorelaiso
Copy link
Collaborator

salvatorelaiso commented Feb 5, 2024

The mixed approach was probably a solution to reference an already defined variable in the docker-compose.yaml file, e.g.:

- SATOSA_BASE=https://$HOSTNAME
- SATOSA_BASE_STATIC=https://$HOSTNAME/static
- SATOSA_DISCO_SRV=https://$HOSTNAME/static/disco.html
- SATOSA_UNKNOW_ERROR_REDIRECT_PAGE=https://$HOSTNAME/static/error_page.html

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.

@MdreW
Copy link
Collaborator Author

MdreW commented Feb 9, 2024

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}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants