Free and open source ticket system written in python
1# Deploying paw with Docker Compose
2
3## Prerequisites
4
5- [Docker installed](https://docs.docker.com/engine/install/) on your machine
6- Docker Compose plugin installed on your machine
7
8## Deployment with `sqlite` database
9
10Example `docker-compose.yml` file:
11
12```yaml
13services:
14 paw:
15 image: ghcr.io/aottr/paw:latest
16 command: gunicorn paw.wsgi:application --bind 0.0.0.0:8000
17 container_name: paw-ticket-system
18 restart: unless-stopped
19 ports:
20 - "127.0.0.1:8000:8000"
21 volumes:
22 - db:/usr/src/app/data
23 - media:/usr/src/app/media
24 - secure_media:/usr/src/app/secure_media # storage for ticket attachments
25 environment:
26 - DATABASE_ENGINE=sqlite3
27 - DEBUG=true
28 - ALLOWED_HOSTS=example.org,example.com
29 - SECRET_KEY=your-secret-key
30```
31
32The env variable `DATABASE_ENGINE` must be set to `sqlite3`, otherwise paw expects database credentials and another supported engine, e.g. `postgresql`
33
34### Production Deployment
35
36If, for whatever reason, a production deployment should be used with **sqlite3**, the `media` files need to be served with a webserver / reverse proxy, e.g. nginx. This should also happen with static files.
37
38For this we slightly modify the deployment volumes:
39
40```yaml
41volumes:
42 - /opt/paw/data:/usr/src/app/data
43 - /opt/paw/media:/usr/src/app/media
44 - /opt/paw/static:/usr/src/app/static
45 - /opt/paw/secure_media:/usr/src/app/secure_media # storage for ticket attachments
46```
47
48Now you write directives in your config to host these files, the following snipped shows an example nginx config:
49
50#### Example nginx config
51
52```nginx
53upstream paw {
54 server localhost:8000;
55}
56
57server {
58
59 server_name example.org example.com
60 listen 80;
61 listen [::]:80;
62
63 location /media/ {
64 # media files, uploaded by us (profile pictures, etc.)
65 alias /opt/paw/media/; # ending slash is required
66 }
67
68 location /static/ {
69 # static files, uploaded by the system
70 alias /opt/paw/static/; # ending slash is required
71 }
72
73 location / {
74 proxy_pass http://paw;
75 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
76 proxy_set_header Host $host;
77 proxy_redirect off;
78 }
79}
80```
81
82#### Example Caddyfile
83
84```
85example.com {
86
87 handle /static/* {
88 file_server /opt/paw/static/*
89 }
90
91 handle /media/* {
92 file_server /opt/paw/media/*
93 }
94
95 handle {
96 reverse_proxy 127.0.0.1:8000
97 }
98}
99```
100
101That's it! You have successfully deployed your project using Docker Compose.