pulp / pulp-oci-images

Containerfiles and other assets for building Pulp 3 OCI images
https://docs.pulpproject.org/pulp_oci_images/
34 stars 55 forks source link

Dynaconf / Django settings via Environmental Variable are not being consumed #97

Open ajsween opened 3 years ago

ajsween commented 3 years ago

https://dynaconf.readthedocs.io/en/docs_223/guides/environment_variables.html https://pulpproject.org/2018/09/25/pulp-3-adopts-dynaconf/ https://docs.pulpproject.org/pulpcore/configuration/applying.html#by-environment-variables

As documented by the dynaconf project and in the Pulp documentation, it should be possible to avoid configuration of the container via mounting the settings.py file to /etc/pulp/settings.py. However, when setting the environment variables using the "PULP_" prefix and excluding the settings.py file mount the try statement at https://github.com/pulp/pulpcore/blob/58873f3c80fa6cc3931b5b6591b9e856ff98581b/pulpcore/app/settings.py#L288 throws an exception stating that CONTENT_ORIGIN is not set.

I added the following config to my docker-compose.yml file via a .env file and the env-file: attribute.

PULP_CONTENT_ORIGIN='http://$(hostname):8080'
PULP_ANSIBLE_API_HOSTNAME='http://$(hostname):8080'
PULP_ANSIBLE_CONTENT_HOSTNAME='http://$(hostname):8080/pulp/content'
PULP_TOKEN_AUTH_DISABLED=True

I've verified the variables are being correctly imported by dynaconf via a docker-exec into the running container and running dynaconf list --all

Am I missing something?

mikedep333 commented 1 year ago

Hi @ajsween

s6, the service manager in the container, blocks every single environment variable from being seen by the services it starts unless we specifically whitelist the environment variable by running "importas" and "export" for the env var.

I need to look into how to stop it from doing this, or have it whitelist all "PULP_" variables.

mikedep333 commented 1 year ago

Best way to do this is to set S6_KEEP_ENV=1