7e8390b228
Der Server holt sich den Abzug selbst über DUMP_URL, statt dass Postgres einen Port nach außen öffnen müsste. Ohne die Variable beendet sich der Dienst sofort, er kann also dauerhaft im Stack bleiben. Das Backend wartet jetzt auf diesen Dienst statt direkt auf die Migration — sonst liefe es beim Einspielen gegen wechselnde Tabellen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
141 lines
4.8 KiB
YAML
141 lines
4.8 KiB
YAML
# Stack für Portainer auf dem Orange Pi.
|
|
#
|
|
# Die Images kommen fertig aus der Gitea-Registry, hier wird nichts gebaut —
|
|
# ein Medusa-Build auf dem Pi dauert eine halbe Stunde, auf dem Mac drei
|
|
# Minuten. Gebaut und hochgeladen wird mit ./deploy.sh.
|
|
#
|
|
# Alles Veränderliche liegt außerhalb der Images:
|
|
# - Datenbank, Redis und Uploads als Ordner auf dem Pi unter DATA_DIR
|
|
# (Standard /srv/place4bees). Damit sind sie sichtbar, sicherbar und
|
|
# überstehen jedes Neuladen des Stacks.
|
|
# - Zugangsdaten als Variablen des Stacks (in Portainer unter "Environment")
|
|
#
|
|
# Vor dem ersten Deploy auf dem Pi anlegen:
|
|
# sudo mkdir -p /srv/place4bees/{postgres,redis,uploads}
|
|
#
|
|
# Pflichtvariablen: IMAGE_TAG, POSTGRES_PASSWORD, JWT_SECRET, COOKIE_SECRET,
|
|
# MEDUSA_BACKEND_URL, STORE_CORS, ADMIN_CORS, AUTH_CORS
|
|
|
|
name: place4bees
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_USER: medusa
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: medusa
|
|
volumes:
|
|
- ${DATA_DIR:-/srv/place4bees}/postgres:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U medusa"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
redis:
|
|
image: redis:7-alpine
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ${DATA_DIR:-/srv/place4bees}/redis:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
|
|
# Läuft bei jedem Deploy einmal und beendet sich wieder. Als eigener Dienst,
|
|
# damit im Portainer sofort zu sehen ist, ob die Migration durchlief — sonst
|
|
# steckt der Fehler in den Logs des Backends.
|
|
migrate:
|
|
image: ${REGISTRY:-git.place4bees.com/place4bees}/backend:${IMAGE_TAG:-latest}
|
|
restart: "no"
|
|
command: ["npx", "medusa", "db:migrate"]
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
environment:
|
|
DATABASE_URL: postgres://medusa:${POSTGRES_PASSWORD}@postgres:5432/medusa
|
|
REDIS_URL: redis://redis:6379
|
|
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:
|
|
restore:
|
|
condition: service_completed_successfully
|
|
redis:
|
|
condition: service_healthy
|
|
# Das Image migriert sonst beim Start noch einmal — das macht hier der
|
|
# Dienst oben.
|
|
command: ["npx", "medusa", "start"]
|
|
environment:
|
|
DATABASE_URL: postgres://medusa:${POSTGRES_PASSWORD}@postgres:5432/medusa
|
|
REDIS_URL: redis://redis:6379
|
|
JWT_SECRET: ${JWT_SECRET}
|
|
COOKIE_SECRET: ${COOKIE_SECRET}
|
|
MEDUSA_BACKEND_URL: ${MEDUSA_BACKEND_URL}
|
|
STORE_CORS: ${STORE_CORS}
|
|
ADMIN_CORS: ${ADMIN_CORS}
|
|
AUTH_CORS: ${AUTH_CORS}
|
|
# Bleiben leer, solange die Zugänge fehlen. Die Module melden sich dann
|
|
# gar nicht erst an, statt beim Start zu scheitern.
|
|
DHL_API_KEY: ${DHL_API_KEY:-}
|
|
DHL_USERNAME: ${DHL_USERNAME:-}
|
|
DHL_PASSWORD: ${DHL_PASSWORD:-}
|
|
DHL_BILLING_NUMBER: ${DHL_BILLING_NUMBER:-}
|
|
DHL_SHIPPER_NAME: ${DHL_SHIPPER_NAME:-}
|
|
DHL_SHIPPER_STREET: ${DHL_SHIPPER_STREET:-}
|
|
DHL_SHIPPER_POSTAL_CODE: ${DHL_SHIPPER_POSTAL_CODE:-}
|
|
DHL_SHIPPER_CITY: ${DHL_SHIPPER_CITY:-}
|
|
DHL_SHIPPER_COUNTRY: ${DHL_SHIPPER_COUNTRY:-}
|
|
MOLLIE_API_KEY: ${MOLLIE_API_KEY:-}
|
|
SMTP_HOST: ${SMTP_HOST:-}
|
|
SMTP_PORT: ${SMTP_PORT:-}
|
|
SMTP_USER: ${SMTP_USER:-}
|
|
SMTP_PASSWORD: ${SMTP_PASSWORD:-}
|
|
MAIL_FROM: ${MAIL_FROM:-}
|
|
volumes:
|
|
- ${DATA_DIR:-/srv/place4bees}/uploads:/app/static
|
|
ports:
|
|
- "${BACKEND_PORT:-9001}:9001"
|
|
|
|
frontend:
|
|
image: ${REGISTRY:-git.place4bees.com/place4bees}/frontend:${IMAGE_TAG:-latest}
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- backend
|
|
ports:
|
|
- "${FRONTEND_PORT:-4321}:4321"
|