Commit 043409ce authored by Jon Yu's avatar Jon Yu
Browse files

Update README; tweak build, run

parent 2c99fa65
Pipeline #17197 passed with stage
in 14 seconds
......@@ -2,6 +2,9 @@ FROM python:3.8-slim
......@@ -25,4 +28,4 @@ EXPOSE 8000
ENTRYPOINT ["/usr/src/app/"]
CMD ["gunicorn", "--bind=", "--workers=2", "--threads=4", "--access-logfile=-", "--log-file=-", "um_django_template_project.wsgi"]
\ No newline at end of file
CMD ["gunicorn", "--bind=", "--workers=${GUNICORN_WORKERS}", "--threads=${GUNICORN_THREADS}", "--access-logfile=-", "--log-file=-", "um_django_template_project.wsgi"]
\ No newline at end of file
......@@ -4,6 +4,12 @@ The following project provides a template for creating a Django application with
See the [ITS style guide]( for additional details.
Additional features include:
- Deployment-friendly Dockerfile
- Docker Compose setup for local development
- Basic GitLab CI config
## Starting a base Django project with the Umich template
### Option 1 - Using the helper script
......@@ -27,3 +33,53 @@ Run `django-admin startproject --template ./app [output_dir] [project_name]`
$ docker-compose build
$ docker-compose up
You will likely want to change the name of the base project from um_django_template_project. This will need to happen in various places.
## General deployment checklist
### Generate a unique Django secret key for each environment
To do this using Django's built-in `startproject` algorithm, open up a Django shell and run the following Python code:
from import get_random_secret_key
If you are using the compose setup, you can run the Python code in your container like so:
docker-compose exec app python shell
Set `SECRET_KEY` in your environment with this value and Django will pick it up
### Update
The Dockerfile will install Django requirements based on an optional argument for `ENVIRONMENT`. If unset, it will default to "PRODUCTION" and packages will be installed from
Prior to deployment, it is recommended that you `pip freeze` and copy the exact versions to to prevent unintended side-effects.
If using compose, you can run:
docker-compose exec app pip freeze >
### (Optional) Update settings for Django error emails
Set the following environment variables:
- EMAIL_HOST (use UM mail relay)
### (Optional) Tweak Gunicorn settings
The number of workers and threads can be set via environment variables, `GUNICORN_WORKERS` and `GUNICORN_THREADS` respectively.
There is an article [here]( that suggests that
> maximum concurrent requests when using workers and threads is still(2*CPU)+1
\ No newline at end of file
......@@ -4,5 +4,6 @@ set -e
python3 collectstatic --noinput
python3 migrate
python3 check --deploy
exec "${@}"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment