No description
Find a file
2025-09-02 10:00:55 +02:00
.gitignore update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
backup.sh update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
check_ssl.sh update setup 2025-08-30 14:21:29 +02:00
compose.override.yml update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
compose.yml update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
Dockerfile initial commit 2025-08-29 16:06:45 +02:00
example.env update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
README.md update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00
setup.sh update and exclude nginx to separate stack 2025-09-02 10:00:55 +02:00

pretix Docker Compose Setup

This repository contains a Docker Compose setup for running pretix - an open-source event ticketing platform. This setup is based on the official pretix Docker documentation but uses Docker Compose for easier management.

Architecture

This setup runs pretix with the following components:

  • pretix: Main application (custom built with plugins)
  • PostgreSQL: Database server for data persistence
  • Redis: Caching and message broker for background tasks

All data and configuration are persisted through Docker volumes. This setup is designed to run behind a reverse proxy (nginx setup is separate).

Prerequisites

  • Docker and Docker Compose installed
  • A SMTP server for sending emails
  • Reverse proxy setup (nginx) for SSL termination and domain routing
  • Firewall configured (recommended)

Quick Start

  1. Clone or download this repository

    git clone <repository-url>
    cd pretix-docker
    
  2. Create environment file

    cp example.env .env
    
  3. Configure environment variables

    # Edit .env with your values
    PRETIX_VERSION=2025.7
    POSTGRES_DB=pretix
    POSTGRES_USER=pretix
    POSTGRES_PASSWORD=my_secret_password
    
  4. Run the setup script

    # This will create necessary directories and networks
    ./setup.sh
    
  5. Start the services

    docker compose up -d --build
    

    Docker Compose automatically applies compose.override.yml. This attaches the pretix service to the external reverse-proxy network (and avoids exposing direct ports).

  6. Access pretix

Configuration

Compose Override

This project includes a compose.override.yml that Docker Compose loads automatically. It connects the pretix service to the external reverse-proxy network for access via the nginx reverse proxy.

  • Ensure the reverse-proxy network exists (usually created by the nginx setup).
  • Prefer defining network membership in your Compose files over manual docker network connect commands.

Environment Variables

Variable Description Example
PRETIX_VERSION pretix version to use 2025.7
POSTGRES_DB PostgreSQL database name pretix
POSTGRES_USER PostgreSQL username pretix
POSTGRES_PASSWORD PostgreSQL password my_secret_password

Volume Mappings

Host Path Container Path Purpose
./pretix-data /var/pretix/data pretix data files
./pretix-config /etc/pretix pretix configuration
./pgdata /var/lib/postgresql/data PostgreSQL data

Services

pretix

  • Image: Custom built from pretix/standalone:${PRETIX_VERSION}
  • Plugins: Includes pretix-passbook plugin
  • Features: Web interface, API, background tasks
  • Access: Through reverse proxy network
  • Network: Connected to reverse-proxy network for external access

PostgreSQL

  • Image: postgres:13
  • Purpose: Primary database for all pretix data
  • Persistence: Data stored in ./pgdata volume
  • Security: Password-protected, internal network only

Redis

  • Image: redis:alpine
  • Purpose: Caching and message broker for Celery tasks
  • Features: Session storage, background job queue
  • Persistence: In-memory with optional persistence

Network Configuration

Docker Networks

The setup uses the reverse-proxy network to communicate with the nginx reverse proxy:

# Create network if not exists (usually done by nginx setup)
docker network create reverse-proxy

# Connect pretix to the network
docker network connect reverse-proxy pretix

Note: Using compose.override.yml, pretix is already attached to reverse-proxy. Defining the network under services.pretix.networks in Compose keeps the configuration persistent across restarts.

Reverse Proxy Integration

This pretix setup is designed to work with a separate nginx reverse proxy that:

  • Handles SSL termination
  • Routes traffic based on domain names
  • Provides PROXY protocol support
  • Manages client IP forwarding

Customization

Adding Plugins

  1. Edit the Dockerfile:

    FROM pretix/standalone:${PRETIX_VERSION}
    USER root
    RUN pip3 install pretix-passbook pretix-your-plugin
    USER pretixuser
    RUN cd /pretix/src && make production
    
  2. Rebuild the container:

    docker compose build
    

pretix Configuration

Create ./pretix-config/pretix.cfg:

[pretix]
instance_name=My pretix installation
url=https://yourdomain.com
currency=EUR
datadir=/var/pretix/data
trust_x_forwarded_for=on
trust_x_forwarded_proto=on

[database]
backend=postgresql
name=pretix
user=pretix
password=my_secret_password
host=pretix-db

[mail]
from=tickets@yourdomain.com
host=your-smtp-server.com
port=587
username=your-username
password=your-password
use_tls=True

[redis]
location=redis://pretix-redis:6379/0
sessions=true

[celery]
backend=redis://pretix-redis:6379/1
broker=redis://pretix-redis:6379/2

Maintenance

Updates

  1. Edit version in .env:

    PRETIX_VERSION=2025.8
    
  2. Rebuild and restart:

    docker compose down
    docker compose up -d --build
    
  3. Run database migrations:

    docker compose exec -it pretix pretix upgrade
    

Backups

Backups are handled by a cron job that runs the provided backup.sh script as root at the beginning of every month. No logging/output is stored.

  1. Ensure the script is executable:
chmod +x /srv/pretix/backup.sh
  1. Install the cron entry for root:
# Run at 00:00 on the 1st day of every month, discard all output
0 0 1 * * /srv/pretix/backup.sh >/dev/null 2>&1

The script creates a PostgreSQL dump, compresses it, saves it to /srv/pretix/backup/, and copies the current pretix.cfg alongside it. Old archives are pruned based on the retention configured in backup.sh.

Database Access

# From container
docker compose exec -it pretix-db psql -U pretix -d pretix

Logs

# All services
docker compose logs -f

# Specific service
docker compose logs -f pretix

Cron Jobs

# Add to crontab
15,45 * * * * /usr/bin/docker exec pretix-pretix-1 pretix cron

Testing

Test your pretix installation:

# Check if pretix is responding
docker compose exec pretix curl -I http://localhost

# Check database connection
docker compose exec pretix-db pg_isready -U pretix

# Check Redis connection
docker compose exec pretix-redis redis-cli ping

Debugging

# Check service status
docker compose ps

# View pretix logs
docker compose logs pretix

# Check network connectivity
docker compose exec pretix ping pretix-db
docker compose exec pretix ping pretix-redis

Integration with Reverse Proxy

Requirements for Reverse Proxy

Your reverse proxy (nginx) should:

  1. Be on the same reverse-proxy network
  2. Route traffic to pretix:80
  3. Handle SSL termination
  4. Forward proper headers (X-Forwarded-For, X-Forwarded-Proto, etc.)
  5. Support PROXY protocol if behind a load balancer

Example nginx configuration

server {
    listen 443 ssl proxy_protocol;
    server_name yourdomain.com;

    location / {
        proxy_pass http://pretix:80;
        proxy_set_header X-Real-IP $proxy_protocol_addr;
        proxy_set_header X-Forwarded-For $proxy_protocol_addr;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $http_host;
    }
}

Support

License

This setup is provided as-is. pretix itself is licensed under the Apache License 2.0.