African Cities Lab website africancitieslab.org
- docker
- docker-compose
- ansible
To set up a development environment, install the requirements and initialize pre-commit as follows:
pip install -r requirements/local.txt
pre-commit install
This site is based on the cookiecutter-django template, so further valuable information can also be found in its documentation.
-
Build the stack:
docker-compose -f local.yml build docker-compose -f local.yml up
alternatively, the above commands can be replaced by using the
deploy.local.yml
ansible playbook as in:ansible-playbook ansible/deploy.local.yml
-
Run the migrations:
docker-compose -f local.yml run django python manage.py migrate
-
Create a super user:
docker-compose -f local.yml run django python manage.py createsuperuser
In order to set up the staging and production servers, the following commands should be run once:
-
Create two computing server instances (e.g., AWS EC2, DigitalOcean droplet...), one for staging and another for production, and ensure that you have root ssh access rights to both (e.g., by running
ssh root@<server-ip>
). -
Register a domain and create A DNS records to redirect the to the server IP addresses, e.g., create an A record mapping the base domain (e.g., "example.com") to the production server and another A record mapping a staging subdomain (e.g., "staging.example.com") to the staging server.
-
Execute the
ansible/setup.staging.yml
andansible/setup.production.yml
playbooks to setup the production and staging servers respectively:# ansible-playbook ansible/setup.staging.yml # for staging ansible-playbook ansible/setup.production.yml # for production
-
Create two storage bucket instances (e.g., AWS S3, DigitalOcean spaces...), one for staging and another for production.
-
Ensure that
.envs/.staging/.django
and.envs/.production/.django
have the correct access keys for the staging and production storage buckets respectively.
Once the servers are setup, you can push the latest commit to the main branch of this repository (https://github.com/African-Cities-Lab/african-cities-lab-org) and then deploy them to staging/production by executing the ansible/deploy.staging.yml
and ansible/deploy.production.yml
playbooks respectively:
# ansible-playbook ansible/deploy.staging.yml # for staging
ansible-playbook ansible/deploy.production.yml # for production
The web application should be now up and running in the staging and production servers
- The ansible playbook of this repository is based on the approach of rrebase/knboard.