72. DevOps guide¶
DevOps guide provides structured documentation on DevOps practices, tools, and workflows used in software development and deployment.
73. Deploying with docker¶
This document explains how to do various sysadmin related tasks when your site has been deployed under docker. These deployment modes are supported:
- production: no debug etc is enabled, has its own discrete database. Configure your production environment in core.settings.prod_docker - this DJANGO_SETTINGS_MODULE is used when running in production mode.
- staging: Configure your staging environment in core.settings.staging_docker - this DJANGO_SETTINGS_MODULE is used when running in production mode.
74. Build your docker images and run them¶
74.1 Production¶
You can simply run the provided script and it will build and deploy the docker images for you in production mode.
cd deployment
# allow pg volume to be written to
sudo chmod -R a+rwX pg/postgres_data/
make deploy
sudo chmod -R a+rwX static
74.2 Run in development mode¶
run makedev
in the terminal.
Then connect to the django container and run python manage.py runserver 0.0.0.0:8080
Pycsw runs on port 8000
Now point your browser at the ip of the web container on port 8080 or to the host port mapping as defined in the fig.yml file.
To make a superuser account do:
74.3 Staging¶
The procedure is exactly the same as production, but you should preceed
each command with 'staging' e.g. make staging-deploy
.
Note: VERY IMPORTANT - for staging deployment you should use a separate git checkout from the production checkout as the code from the git checkout is shared into the source tree.
74.4 Using make¶
The following key make commands are provided for production:
- build - build production containers
- run - builds then runs db and uwsgi services
- collectstatic - collect static in production instance
- migrate - run django migrations in production instance
Additional make commands are provided in the Makefile - please see there for details.
74.4.0.1 Arbitrary commands¶
Running arbitrary management commands is easy
74.5 Setup nginx reverse proxy¶
You should create a new nginx virtual host - please see
*-nginx.conf
in the deployment directory for examples. There is
one provided for production and one for staging.
Simply add the example file (renaming them as needed) to your
/etc/nginx/sites-enabled/
directory and then modify the contents to
match your local filesystem paths. Then use
To verify that your configuration is correct and then reload / restart nginx e.g.
74.5.1 Managing containers¶
Please refer to the general fig documentation for further notes on how to manage the infrastructure using fig.
75. Configuration options¶
You can configure the base port used and various other options like the
image organisation namespace and postgis user/pass by editing the fig*.yml
files.