Compare commits
6 Commits
backup_bra
...
1.2.0+2024
| Author | SHA1 | Date | |
|---|---|---|---|
| 9edc8f0ee6 | |||
| 4183ab5c54 | |||
| 9dffdfde39 | |||
| 700a349e55 | |||
| e3e08d0b1d | |||
| 014abccba6 |
@ -17,6 +17,9 @@ steps:
|
||||
DOMAIN: {{ .Name }}.swarm-test.autonomic.zone
|
||||
STACK_NAME: {{ .Name }}
|
||||
LETS_ENCRYPT_ENV: production
|
||||
CRON_ENTRYPOINT_VERSION: v1
|
||||
PRETIX_CONFIG_VERSION: v1
|
||||
PG_BACKUP_VERSION: v1
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
||||
@ -6,6 +6,7 @@ DOMAIN=pretix.example.com
|
||||
#EXTRA_DOMAINS=', `www.pretix.example.com`'
|
||||
|
||||
LETS_ENCRYPT_ENV=production
|
||||
ENABLE_BACKUPS=true
|
||||
|
||||
SECRET_DB_PASSWORD_VERSION=v1
|
||||
SECRET_DJANGO_SECRET_KEY_VERSION=v1
|
||||
|
||||
18
README.md
18
README.md
@ -1,17 +1,17 @@
|
||||
# pretix
|
||||
|
||||
> One line description of the recipe
|
||||
> Ticket shop application for conferences, festivals, concerts, tech events, shows, exhibitions, workshops, barcamps, etc.
|
||||
|
||||
<!-- metadata -->
|
||||
|
||||
* **Category**: Apps
|
||||
* **Status**: 0
|
||||
* **Image**: [`pretix`](https://hub.docker.com/r/pretix), 4, upstream
|
||||
* **Healthcheck**: No
|
||||
* **Backups**: No
|
||||
* **Email**: No
|
||||
* **Healthcheck**: Yes
|
||||
* **Backups**: Yes
|
||||
* **Email**: Yes
|
||||
* **Tests**: No
|
||||
* **SSO**: No
|
||||
* **SSO**: Only supported for customer accounts, see [documentation](https://docs.pretix.eu/en/latest/user/customers/index.html)
|
||||
|
||||
<!-- endmetadata -->
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
* `abra app config <app-name>`
|
||||
* `abra app deploy <app-name>`
|
||||
* If you get an internal server error, try running `pretix migrate` inside the app container
|
||||
* Initial admin is `admin@localhost` with password `admin`
|
||||
* Change immediately via gui or `abra app cmd <DOMAIN> app change_adminpass`
|
||||
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
|
||||
@ -28,7 +30,7 @@ For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
## TODO
|
||||
|
||||
* [X] mail
|
||||
* [ ] healthchecks
|
||||
* [ ] cronjob: 15,45 * * * * /usr/bin/docker exec pretix.service pretix cron
|
||||
* [ ] backups https://docs.pretix.eu/en/latest/admin/maintainance.html#maintainance
|
||||
* [x] healthchecks
|
||||
* [x] cronjob: 15,45 * * * * /usr/bin/docker exec pretix.service pretix cron
|
||||
* [x] backups https://docs.pretix.eu/en/latest/admin/maintainance.html#maintainance
|
||||
* [ ] plugins
|
||||
|
||||
6
abra.sh
6
abra.sh
@ -1 +1,7 @@
|
||||
export PRETIX_CONFIG_VERSION=v1
|
||||
export CRON_ENTRYPOINT_VERSION=v1
|
||||
export PG_BACKUP_VERSION=v1
|
||||
|
||||
change_adminpass(){
|
||||
python -m django changepassword admin@localhost
|
||||
}
|
||||
|
||||
46
compose.yml
46
compose.yml
@ -3,7 +3,7 @@ version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
image: 'pretix/standalone:2024.1.0'
|
||||
image: 'pretix/standalone:2024.10.0'
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
@ -25,13 +25,13 @@ services:
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
- "coop-cloud.${STACK_NAME}.version=1.0.0+2024.1.0"
|
||||
# healthcheck:
|
||||
# test: ["CMD", "curl", "-f", "http://localhost"]
|
||||
# interval: 30s
|
||||
# timeout: 10s
|
||||
# retries: 10
|
||||
# start_period: 1m
|
||||
- "coop-cloud.${STACK_NAME}.version=1.2.0+2024.10.0"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/healthcheck"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 1m
|
||||
|
||||
db:
|
||||
image: postgres:12
|
||||
@ -45,6 +45,10 @@ services:
|
||||
POSTGRES_DB: pretix
|
||||
secrets:
|
||||
- db_password
|
||||
configs:
|
||||
- source: pg_backup
|
||||
target: /pg_backup.sh
|
||||
mode: 0555
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
|
||||
interval: 10s
|
||||
@ -52,9 +56,10 @@ services:
|
||||
retries: 5
|
||||
deploy:
|
||||
labels:
|
||||
backupbot.backup: "true"
|
||||
backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/backup.sql"
|
||||
backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/backup.sql"
|
||||
backupbot.backup: "${ENABLE_BACKUPS:-true}"
|
||||
backupbot.backup.pre-hook: "/pg_backup.sh backup"
|
||||
backupbot.backup.volumes.database.path: "backup.sql"
|
||||
backupbot.restore.post-hook: '/pg_backup.sh restore'
|
||||
|
||||
redis:
|
||||
image: redis:7.0.10-alpine
|
||||
@ -68,6 +73,19 @@ services:
|
||||
networks:
|
||||
- internal
|
||||
|
||||
cron:
|
||||
image: alpinelinux/docker-cli:latest
|
||||
environment:
|
||||
- STACK_NAME=${STACK_NAME}
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
entrypoint:
|
||||
/entrypoint.sh
|
||||
configs:
|
||||
- source: cron_entrypoint
|
||||
target: /entrypoint.sh
|
||||
mode: 0555
|
||||
|
||||
volumes:
|
||||
app:
|
||||
postgres:
|
||||
@ -78,6 +96,12 @@ configs:
|
||||
name: ${STACK_NAME}_pretix_config_${PRETIX_CONFIG_VERSION}
|
||||
file: pretix.cfg.tmpl
|
||||
template_driver: golang
|
||||
cron_entrypoint:
|
||||
name: ${STACK_NAME}_cron_entrypoint_${CRON_ENTRYPOINT_VERSION}
|
||||
file: entrypoint.cron.sh
|
||||
pg_backup:
|
||||
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
||||
file: pg_backup.sh
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
|
||||
3
entrypoint.cron.sh
Normal file
3
entrypoint.cron.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo '15,45 * * * * docker exec $(docker ps -qf 'name=${STACK_NAME}_app') pretix runperiodic' | crontab - && crond -f -d 8
|
||||
34
pg_backup.sh
Normal file
34
pg_backup.sh
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BACKUP_FILE='/var/lib/postgresql/data/backup.sql'
|
||||
|
||||
function backup {
|
||||
export PGPASSWORD=$(cat /run/secrets/db_password)
|
||||
pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} > $BACKUP_FILE
|
||||
}
|
||||
|
||||
function restore {
|
||||
cd /var/lib/postgresql/data/
|
||||
restore_config(){
|
||||
# Restore allowed connections
|
||||
cat pg_hba.conf.bak > pg_hba.conf
|
||||
su postgres -c 'pg_ctl reload'
|
||||
}
|
||||
# Don't allow any other connections than local
|
||||
cp pg_hba.conf pg_hba.conf.bak
|
||||
echo "local all all trust" > pg_hba.conf
|
||||
su postgres -c 'pg_ctl reload'
|
||||
trap restore_config EXIT INT TERM
|
||||
|
||||
# Recreate Database
|
||||
psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);"
|
||||
createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
|
||||
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
|
||||
|
||||
trap - EXIT INT TERM
|
||||
restore_config
|
||||
}
|
||||
|
||||
$@
|
||||
Reference in New Issue
Block a user