···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+volumes:
4141+ - db:/usr/src/app/db.sqlite3
4242+ - /opt/paw/media:/usr/src/app/media
4343+ - /opt/paw/static:/usr/src/app/static
4444+```
4545+4646+Now you write directives in your config to host these files, the following snipped shows an example nginx config:
4747+4848+#### Example nginx config
4949+5050+```nginx
5151+upstream paw {
5252+ server localhost:8000;
5353+}
5454+5555+server {
5656+5757+ server_name example.org example.com
5858+ listen 80;
5959+ listen [::]:80;
6060+6161+ location /media/ {
6262+ # media files, uploaded by us
6363+ alias /opt/paw/media/; # ending slash is required
6464+ }
6565+6666+ location /static/ {
6767+ # static files, uploaded by the system
6868+ alias /opt/paw/static/; # ending slash is required
6969+ }
7070+7171+ location / {
7272+ proxy_pass http://paw;
7373+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
7474+ proxy_set_header Host $host;
7575+ proxy_redirect off;
7676+ }
7777+}
7878+```
7979+8080+#### Example Caddyfile
8181+8282+```
8383+example.com {
8484+8585+ handle /static/* {
8686+ file_server /opt/paw/static/*
8787+ }
8888+8989+ handle /media/* {
9090+ file_server /opt/paw/media/*
9191+ }
9292+9393+ handle {
9494+ reverse_proxy 127.0.0.1:8000
9595+ }
9696+}
9797+```
9898+9999+That's it! You have successfully deployed your project using Docker Compose.