Last active
January 10, 2022 19:17
-
-
Save tiefpunkt/11c2d3183986b7f41fbcd2f764166e20 to your computer and use it in GitHub Desktop.
Run Pretix in Docker, incl. DB and Redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run Pretix in Docker, with DB and Redis also as docker containers | |
# This exposes Pretix on port 8080 without TLS. | |
# Make sure to provide a reverse proxy for proper TLS termination. | |
# DO NOT RUN WITHOUT TLS! | |
# Create local directories for the DB and Pretix itself | |
mkdir -p /data/pretix/{db,config,data} | |
touch /data/pretix/config/pretix.cfg | |
chown -R 15371:15371 /data/pretix/{config,data} | |
chmod 0700 /data/pretix/config/pretix.cfg | |
# Edit the pretix config file | |
cat > << EOF | |
[pretix] | |
instance_name=My pretix installation | |
url=https://tickets.example.com | |
currency=EUR | |
; DO NOT change the following value, it has to be set to the location of the | |
; directory *inside* the docker container | |
datadir=/data | |
[database] | |
backend=mysql | |
name=pretix | |
user=pretix | |
password=*************** | |
host=mysql | |
[mail] | |
from=tickets@example.com | |
host=mail.example.com | |
user=tickets@example.com | |
password=***** | |
port=25 | |
tls=on | |
[redis] | |
location=redis://redis:6379/0 | |
sessions=true | |
[celery] | |
backend=redis://redis:6379/1 | |
broker=redis://redis:6379/2 | |
EOF | |
# Create systemd unit files for redis, mariadb and pretix itself | |
cat > /lib/systemd/system/docker-pretix-app.service <<EOF | |
[Unit] | |
Description=Pretix App | |
After=docker-pretix-db.service | |
Requires=docker-pretix-db.service | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
ExecStartPre=-/usr/bin/docker kill pretix_app | |
ExecStartPre=-/usr/bin/docker rm pretix_app | |
ExecStart=/usr/bin/docker run --name pretix_app \ | |
-v /data/pretix/data:/data \ | |
-v /data/pretix/config:/etc/pretix \ | |
--link pretix_db:mysql \ | |
--link pretix_redis:redis \ | |
-p 8080:80 \ | |
makervan/pretix | |
ExecStop=/usr/bin/docker stop -t 10 pretix_app | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat > /lib/systemd/system/docker-pretix-db.service <<EOF | |
[Unit] | |
[Unit] | |
Description=Pretix DB | |
After=docker.service | |
Requires=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
ExecStartPre=-/usr/bin/docker kill pretix_db | |
ExecStartPre=-/usr/bin/docker rm pretix_db | |
ExecStart=/usr/bin/docker run --name pretix_db \ | |
-v /data/pretix/db:/var/lib/mysql \ | |
-e MYSQL_ROOT_PASSWORD=************* \ | |
-e MYSQL_DATABASE=pretix \ | |
-e MYSQL_USER=pretix \ | |
-e MYSQL_PASSWORD=*************** \ | |
mariadb:10.2 | |
ExecStop=/usr/bin/docker stop -t 20 pretix_db | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat > /lib/systemd/system/docker-pretix-redis.service <<EOF | |
[Unit] | |
Description=Pretix Redis | |
After=docker.service | |
Requires=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
ExecStartPre=-/usr/bin/docker kill pretix_redis | |
ExecStartPre=-/usr/bin/docker rm pretix_redis | |
ExecStart=/usr/bin/docker run --name pretix_redis \ | |
redis | |
ExecStop=/usr/bin/docker stop -t 10 pretix_redis | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# Start the three components | |
systemctl daemon-reload | |
systemctl start docker-pretix-redis.service | |
systemctl start docker-pretix-db.service | |
systemctl start docker-pretix-app.service | |
systemctl enable docker-pretix-redis.service | |
systemctl enable docker-pretix-db.service | |
systemctl enable docker-pretix-app.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment