diff --git a/compose.prod.yml b/compose.prod.yml index 81ca652..6b504ef 100644 --- a/compose.prod.yml +++ b/compose.prod.yml @@ -61,11 +61,39 @@ services: JWT_SECRET: ${JWT_SECRET} COOKIE_SECRET: ${COOKIE_SECRET} + # Spielt einen Datenbankabzug ein — aber nur, wenn DUMP_URL gesetzt ist. + # Ohne die Variable beendet sich der Dienst sofort und rührt nichts an, er + # kann also dauerhaft im Stack bleiben. + # + # ACHTUNG: Ein Abzug ersetzt den gesamten Datenbestand. DUMP_URL nach dem + # Einspielen wieder leeren, sonst wird bei jedem Update zurückgesetzt. + restore: + image: postgres:16-alpine + restart: "no" + depends_on: + migrate: + condition: service_completed_successfully + environment: + PGPASSWORD: ${POSTGRES_PASSWORD} + DUMP_URL: ${DUMP_URL:-} + command: + - sh + - -c + - | + if [ -z "$$DUMP_URL" ]; then + echo "DUMP_URL ist nicht gesetzt — es wird nichts eingespielt." + exit 0 + fi + apk add --no-cache curl >/dev/null + echo "Hole Abzug von $$DUMP_URL" + curl -fsS "$$DUMP_URL" | psql -h postgres -U medusa -d medusa + echo "Abzug eingespielt." + backend: image: ${REGISTRY:-git.place4bees.com/place4bees}/backend:${IMAGE_TAG:-latest} restart: unless-stopped depends_on: - migrate: + restore: condition: service_completed_successfully redis: condition: service_healthy