EPFL STI DevOps Challenge v 0.40
As requested per the challenge task (found here https://github.com/jaepetto/STI-devops-challenge), this repository includes 4 main components
- Django web container, running Gunicorn server, based on https://github.com/realpython/dockerizing-django
- 2 Nginx reverse proxy contianers
- PostgreSQL DB container
- HaProxy Load Balancer container
-
Prerequisites
docker
docker-compose
snap
-
Setup In order to run initial setup on Ubuntu, either run
./setup.sh
or
sudo snap install docker
-
Build In order to build the container, run
docker-compose up -d --build
-
Prepare Django You also need to migrate Django DBs to PostgreSQL DB. For that, run:
nano epflchallenge/apps/todo/migrations/__init__.py
then (based on previous experience, running migrations outside of container's bash may not complete successfully)
docker run -ti epfl_challenge_web_1 bash
then
mkdir epflchallenge/apps/todo/migrations
then
python manage.py makemigrations
and finally
python manage.py migrate
-
Find the IP
docker inspect web
-
Go to the IP and see the page
Several important comments:
- The application uses
.env
file to store environment variables, such as PostgreSQL host, user and password, for use in Djangosettings.py
- HaProxy uses a script to open the ports
- Failover can be increased by simply adding additional Nginx node in
docker_compose.yml
andhaproxy.cfg
- HaProxy and Nginx can be configured to accept connections over HTTPS, which is important in this day and age.
- In order to update containers without downtime, it's enough to run
docker-compose up -d --build