This project implements the data harmonization website by Dockerizing Django with Postgres, Gunicorn, and Nginx.
Uses the default Django development server.
-
Rename config/.env.dev-sample to config/.env.dev.
-
Update the environment variables in the docker-compose.yml and config/.env.dev files.
-
Build the images and run the containers:
$ cp config/.env.dev-sample config/.env.dev $ cp config/.env-api.dev-sample config/.env-api.dev $ CURRENT_UID=$(id -u):$(id -g) DEV_UID=$(id -u) docker-compose up -d --build
Test it out at http://localhost:80. The "app" folder is mounted into the container and your code changes apply automatically.
Furthermore, admins can access a custom django-jupyter-notebook kernel on port 7777:
# In a new shell
$ docker-compose exec api /bin/bash
(api)$ python manage.py shell_plus --notebook
Take note of the token and use it in your browser address bar:
http://<ip of the host>:7777/?token=<token number>
Uses gunicorn + nginx.
-
Rename config/.env.prod-sample to config/.env.prod and config/.env.prod.db-sample to config/.env.prod.db. Update the environment variables.
-
Create a self signed certficate for HTTPS encryption
-
Build the images and run the containers:
$ cp config/.env.prod-sample config/.env.prod $ cp config/.env.prod.db-sample config/.env.prod.db # Modify config/.env.prod.db to include the machine's IP to DJANGO_ALLOWED_HOSTS $ openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out config/nginx/localhost.crt -keyout config/nginx/localhost.key < config/.ssl-vals-sample $ docker-compose -f docker-compose.prod.yml up -d --build
Test it out at http://localhost:1337. No mounted folders. To apply changes, the image must be re-built.
This project was build on top of different amazing tutorials: