15 Commits

Author SHA1 Message Date
b6b52b6e9c chore: publish 2.1.0+6.5.0-34 release
All checks were successful
continuous-integration/drone/tag Build is passing
2025-05-27 16:25:24 +02:00
d7dbf76a53 fix saml logout url 2025-01-21 16:10:01 +01:00
f80f630304 Update .drone.yml 2025-01-08 10:09:13 -08:00
73e9f7bfcc chore: publish 2.0.0+6.4.0-34 release
All checks were successful
continuous-integration/drone/tag Build is passing
2024-12-03 18:34:35 +01:00
3a940d845f update pg_backup.sh 2024-10-22 21:33:15 +02:00
d7b3c1e18e add ENABLE_BACKUPS label 2024-10-22 17:28:22 +02:00
3af308645e chore: publish 1.0.5+6.3.1-95 release
All checks were successful
continuous-integration/drone/tag Build is passing
2024-10-15 19:06:10 +02:00
cb85124b06 Add postgres backup script pg_backup 2024-10-15 17:25:01 +02:00
d68c9ad18c chore: publish 1.0.4+6.3.1-95 release 2024-09-19 23:34:07 +02:00
38682b8503 add backupbot label 2024-09-19 23:23:06 +02:00
ce314169cb move zammad internal backups to compose overwrite 2024-09-19 23:18:28 +02:00
34be0c287e fix elasticsearch resources limits 2024-09-19 23:12:12 +02:00
aab7e022d0 chore: publish 1.0.3+6.3.1-95 release 2024-09-17 12:49:44 +02:00
a7e409b337 fix set_logo and enable_authentik_sso 2024-09-17 12:46:33 +02:00
ffe4fa1c54 fix init: remove LOGO_URL 2024-09-03 19:12:30 +02:00
7 changed files with 115 additions and 50 deletions

View File

@ -32,7 +32,7 @@ steps:
from_secret: drone_abra-bot_token
fork: true
repositories:
- coop-cloud/auto-recipes-catalogue-json
- toolshed/auto-recipes-catalogue-json
trigger:
event: tag

View File

@ -2,11 +2,13 @@ TYPE=zammad
DOMAIN=zammad.example.com
TIMEOUT=600
ENABLE_BACKUPS=true
## Domain aliases
#EXTRA_DOMAINS=', `www.zammad.example.com`'
LETS_ENCRYPT_ENV=production
COMPOSE_FILE="compose.yml"
SECRET_DB_PASSWORD_VERSION=v1
SECRET_SMTP_PASSWORD_VERSION=v1
@ -27,4 +29,10 @@ SMTP_PORT=465
## SAML SSO ##
#SSO_PROVIDER_DOMAIN=authentik.example.com
#IDP_SSO_TARGET_URL=https://authentik.example.com/application/saml/zammad/sso/binding/init/
#IDP_SLO_SERVICE_URL=https://authentik.example.com/application/saml/zammad/slo/binding/redirect/
#IDP_SLO_SERVICE_URL=https://zammad.example.com/auth/saml/slo
## Zammad internal backups
# COMPOSE_FILE="$COMPOSE_FILE:compose.backup.yml"
# BACKUP_TIME=03:00"
# HOLD_DAYS=10

View File

@ -1,5 +1,6 @@
export ENTRYPOINT_VERSION=v2
export AUTO_WIZARD_VERSION=v1
export AUTO_WIZARD_VERSION=v2
export PG_BACKUP_VERSION=v2
get_setting_changes() {
/custom-entrypoint.sh "rails r 'puts JSON.pretty_generate(JSON.parse(Setting.all.select{ |setting| setting.state_current != setting.state_initial }.map { |setting| {name: setting.name, value: setting.state_current[\""value\""]} } .to_json))'"
@ -35,7 +36,7 @@ enable_authentik_sso() {
'idp_cert_fingerprint'=>'',
'name_identifier_format'=>'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'})
"
abra app cmd -T -C support.dev.local-it.cloud zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
abra app cmd -T $DOMAIN zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
}
set_logo() {
@ -48,5 +49,5 @@ set_logo() {
logo_timestamp = Service::SystemAssets::ProductLogo.store(logo_content);
Setting.set('product_logo', logo_timestamp);
"
abra app cmd -T -C support.dev.local-it.cloud zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
abra app cmd -T $DOMAIN zammad-railsserver rails_run "$(printf "%q " $COMMAND )"
}

View File

@ -46,10 +46,6 @@
"name": "organization",
"value": "{{ env "ORGANIZATION" }}"
},
{
"name": "product_logo",
"value": "{{ env "LOGO_URL" }}"
},
{
"name": "timezone_default",
"value": "{{ env "TZ" }}"

36
compose.backup.yml Normal file
View File

@ -0,0 +1,36 @@
version: "3.8"
services:
zammad-backup:
image: ghcr.io/zammad/zammad:6.5.0-34
command: ["zammad-backup"]
volumes:
- zammad-backup:/var/tmp/zammad
- zammad-storage:/opt/zammad/storage:ro
user: 0:0
deploy:
labels:
backupbot.backup.volumes.zammad-backup: "false"
restart_policy:
condition: on-failure
environment:
POSTGRESQL_DB: zammad_production
POSTGRESQL_HOST: zammad-postgresql
POSTGRESQL_USER: zammad
POSTGRESQL_PASS_FILE: /run/secrets/db_password
POSTGRESQL_PORT: 5432
# Backup settings
BACKUP_DIR: "/var/tmp/zammad"
BACKUP_TIME: "${BACKUP_TIME:-03:00}"
#BACKUP_SLEEP: 86400
HOLD_DAYS: 10
DOMAIN:
entrypoint: /custom-entrypoint.sh
configs:
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
secrets:
- db_password
volumes:
zammad-backup:

View File

@ -13,11 +13,6 @@ x-shared:
POSTGRESQL_OPTIONS: ?pool=50
POSTGRESQL_DB_CREATE:
REDIS_URL: redis://zammad-redis:6379
# Backup settings
BACKUP_DIR: "/var/tmp/zammad"
BACKUP_TIME: "${BACKUP_TIME:-03:00}"
#BACKUP_SLEEP: 86400
HOLD_DAYS: 10
TZ: "${TZ:-Europe/Berlin}"
# Allow passing in these variables via .env:
AUTOWIZARD_JSON:
@ -48,48 +43,39 @@ x-shared:
SSO_PROVIDER_DOMAIN:
IDP_SSO_TARGET_URL:
IDP_SLO_SERVICE_URL:
image: ghcr.io/zammad/zammad:6.3.1-95
image: ghcr.io/zammad/zammad:6.5.0-34
deploy:
restart_policy:
condition: on-failure
volumes:
- zammad-storage:/opt/zammad/storage
#old: - zammad-data:/opt/zammad
depends_on:
- zammad-memcached
- zammad-postgresql
- zammad-redis
entrypoint: /custom-entrypoint.sh
configs:
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
- source: auto_wizard
target: /opt/zammad/contrib/auto_wizard.json
- source: entrypoint
target: /custom-entrypoint.sh
mode: 0555
- source: auto_wizard
target: /opt/zammad/contrib/auto_wizard.json
secrets:
- db_password
- smtp_password
- admin_password
services:
zammad-backup:
<<: *zammad-service
command: ["zammad-backup"]
volumes:
- zammad-backup:/var/tmp/zammad
- zammad-storage:/opt/zammad/storage:ro
#old: - zammad-data:/opt/zammad
user: 0:0
deploy:
labels:
- "backupbot.backup=true"
- "backupbot.backup.path=/var/tmp/zammad"
zammad-elasticsearch:
image: bitnami/elasticsearch:8.14.3
image: bitnami/elasticsearch:8.18.0
deploy:
restart_policy:
condition: on-failure
resources:
limits:
memory: 4G
reservations:
memory: 2G
volumes:
- elasticsearch-data:/bitnami/elasticsearch/data
environment:
@ -100,13 +86,7 @@ services:
timeout: 10s
retries: 10
start_period: 5m
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 2G
zammad-init:
<<: *zammad-service
command: ["zammad-init"]
@ -116,7 +96,7 @@ services:
zammad-memcached:
command: memcached -m 256M
image: memcached:1.6.29-alpine
image: memcached:1.6.38-alpine
healthcheck:
test: 'echo "version" | nc -vn -w 1 127.0.0.1 11211'
interval: 30s
@ -150,7 +130,7 @@ services:
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
- "coop-cloud.${STACK_NAME}.version=1.0.2+6.3.1-95"
- "coop-cloud.${STACK_NAME}.version=2.1.0+6.5.0-34"
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
@ -168,10 +148,19 @@ services:
deploy:
restart_policy:
condition: on-failure
labels:
backupbot.backup: "${ENABLE_BACKUPS:-true}"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgresql-data.path: "backup.sql"
backupbot.restore.post-hook: "/pg_backup.sh restore"
backupbot.backup.volumes.elasticsearch-data: "false"
backupbot.backup.volumes.redis-data: "false"
volumes:
- postgresql-data:/var/lib/postgresql/data
# Backup Restore
#- zammad-backup:/var/tmp/zammad:ro
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
secrets:
- db_password
healthcheck:
@ -191,9 +180,8 @@ services:
retries: 10
start_period: 5m
zammad-redis:
image: redis:7.2.5-alpine
image: redis:7.4.3-alpine
deploy:
restart_policy:
condition: on-failure
@ -210,7 +198,7 @@ services:
<<: *zammad-service
command: ["zammad-scheduler"]
healthcheck:
test: 'ps x | grep "[b]ackground-worker.rb"'
test: 'grep -a "background-worker.rb" -r /proc/[0-9]*/cmdline'
interval: 30s
timeout: 10s
retries: 10
@ -230,7 +218,6 @@ volumes:
elasticsearch-data:
postgresql-data:
redis-data:
zammad-backup:
zammad-storage:
networks:
@ -246,6 +233,9 @@ configs:
name: ${STACK_NAME}_auto_wizard_${AUTO_WIZARD_VERSION}
file: auto_wizard.json.tmpl
template_driver: golang
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh
secrets:
db_password:

34
pg_backup.sh Normal file
View 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
}
$@