Modify uwsgi entrypoint to allow for overriding settings.py #3045
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This minor enhancement adds an if statement to the existing entrypoint_uswgi.sh to allow the settings file in a container to be overridden by one that is bind mounted or otherwise injected into the container at /settings/. If the uwsgi container is started with the path /settings/settings.py, that settings.py file will overwrite the one 'baked" into the Docker container.
Note: If you don't inject a file at /settings/settings.py via a bind mount or similar, there is no change to the current behaviour for the uwsgi container so this will not break any existing container deployments.
This was originally created to work around a bug in django-environ where the conversion of a Bash environmental variable to a complex Python Dict failed. However, it can be useful in other ways as well such as:
This was tested with the following bind mount for the uwsgi container using docker-compose:
where