···11+# Deploying paw with Docker Compose
22+33+## Prerequisites
44+55+- [Docker installed](https://docs.docker.com/engine/install/) on your machine
66+- Docker Compose plugin installed on your machine
77+88+## Deployment with `sqlite` database
99+1010+Example `docker-compose.yml` file:
1111+1212+```yaml
1313+version: "3.8"
1414+services:
1515+ paw:
1616+ image: ghcr.io/aottr/paw:latest
1717+ container_name: paw-ticket-system
1818+ restart: unless-stopped
1919+ ports:
2020+ - "127.0.0.1:8000:8000"
2121+ volumes:
2222+ - db:/usr/src/app/db.sqlite3
2323+ - media:/usr/src/app/media
2424+ environment:
2525+ - DATABASE_ENGINE=sqlite3
2626+ - DEBUG=true
2727+ - ALLOWED_HOSTS=example.org,example.com
2828+ - SECRET_KEY=your-secret-key
2929+```
3030+3131+The env variable `DATABASE_ENGINE` must be set to `sqlite3`, otherwise paw expects database credentials and another supported engine, e.g. `postgresql`
3232+3333+### Production Deployment
3434+3535+If, 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.
3636+3737+For this we slightly modify the deployment volumes:
3838+3939+```yaml
4040+---
4141+volumes:
4242+ - db:/usr/src/app/db.sqlite3
4343+ - /opt/paw/media:/usr/src/app/media
4444+ - /opt/paw/static:/usr/src/app/static
4545+```
4646+4747+Now you write directives in your config to host these files, the following snipped shows an example nginx config:
4848+4949+```nginx
5050+upstream paw {
5151+ server localhost:8000;
5252+}
5353+5454+server {
5555+5656+ server_name example.org example.com
5757+ listen 80;
5858+ listen [::]:80;
5959+6060+ location /media/ {
6161+ # media files, uploaded by us
6262+ alias /opt/paw/media/; # ending slash is required
6363+ }
6464+6565+ location /static/ {
6666+ # static files, uploaded by the system
6767+ alias /opt/paw/static/; # ending slash is required
6868+ }
6969+7070+ location / {
7171+ proxy_pass http://paw;
7272+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
7373+ proxy_set_header Host $host;
7474+ proxy_redirect off;
7575+ }
7676+}
7777+```
7878+7979+That's it! You have successfully deployed your project using Docker Compose.