Run nginx and gunicorn in docker via supervisor #1313
Merged
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.
Currently the nginx process is run in the background of the docker container and the gunicorn process is run in the foreground. This means that if the nginx process crashes, it won't get restarted and the nginx
logs don't show up in the docker logs since only the foreground gunicorn logs are captured. More generally, it is also not recommended to run multiple processes in a single docker container unless a process manager is used (more information).
This change introduces the supervisor process manager to run as the single foreground process in docker. The supervisor process in turn takes care of running both nginx and gunicorn.
Note that supervisor has its own environment variable isolation and doesn't have an easy way of passing all the environment variables to the child process. As a work-around to avoid having to declare all environment variables multiple times, we first dump the environment into files and then reload them in the child process from the files via the envdir utility.
Also:
grep
.bash
executable.