chore(phase0): Prod-Compose (restart, Bind-Mount, Secrets aus .env) + NucBox deploy.sh
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
170e4ddfc1
commit
6918a60388
3 changed files with 35 additions and 15 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -13,3 +13,4 @@ dist/
|
||||||
build/
|
build/
|
||||||
*.db
|
*.db
|
||||||
*.sqlite
|
*.sqlite
|
||||||
|
rechnungen/
|
||||||
|
|
|
||||||
|
|
@ -4,49 +4,45 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.backend
|
dockerfile: Dockerfile.backend
|
||||||
container_name: invoice-check-backend
|
container_name: invoice-check-backend
|
||||||
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8005:8001"
|
- "127.0.0.1:8005:8001"
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgresql://postgres:postgres@db:5432/invoice_check
|
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@db:5432/invoice_check
|
||||||
- SECRET_KEY=${SECRET_KEY}
|
- SECRET_KEY=${SECRET_KEY}
|
||||||
- AWS_DEFAULT_REGION=eu-central-1
|
- AWS_DEFAULT_REGION=eu-central-1
|
||||||
- IMAP_HOST=imap.strato.de
|
- IMAP_HOST=${IMAP_HOST:-imap.strato.de}
|
||||||
- IMAP_PORT=993
|
- IMAP_PORT=${IMAP_PORT:-993}
|
||||||
- IMAP_USER=${IMAP_USER}
|
- IMAP_USER=${IMAP_USER}
|
||||||
- IMAP_PASSWORD=${IMAP_PASSWORD}
|
- IMAP_PASSWORD=${IMAP_PASSWORD}
|
||||||
- SMTP_HOST=smtp.strato.de
|
- INVOICE_STORAGE_PATH=/data/rechnungen
|
||||||
- SMTP_PORT=587
|
|
||||||
- SMTP_USER=${SMTP_USER}
|
|
||||||
- SMTP_PASSWORD=${SMTP_PASSWORD}
|
|
||||||
- INVOICE_STORAGE_PATH=/tmp/invoice-storage
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
networks:
|
networks:
|
||||||
- invoice-check-network
|
- invoice-check-network
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend/tests:/app/backend/tests
|
- ./rechnungen:/data/rechnungen
|
||||||
- /tmp/test-invoices:/tmp/test-invoices
|
|
||||||
- invoice-storage:/tmp/invoice-storage
|
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.frontend
|
dockerfile: Dockerfile.frontend
|
||||||
container_name: invoice-check-frontend
|
container_name: invoice-check-frontend
|
||||||
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "5178:80"
|
- "127.0.0.1:5178:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
networks:
|
networks:
|
||||||
- invoice-check-network
|
- invoice-check-network
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
container_name: invoice-check-db
|
container_name: invoice-check-db
|
||||||
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=postgres
|
- POSTGRES_USER=postgres
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
- POSTGRES_DB=invoice_check
|
- POSTGRES_DB=invoice_check
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-data:/var/lib/postgresql/data
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
|
@ -60,4 +56,4 @@ networks:
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
postgres-data:
|
||||||
invoice-storage:
|
name: invoice-check-postgres-data
|
||||||
|
|
|
||||||
23
scripts/deploy.sh
Executable file
23
scripts/deploy.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Deploy auf die NucBox. Nutzung:
|
||||||
|
# with-secrets.sh invoice-check scripts/deploy.sh [--env-only]
|
||||||
|
# 1) schreibt ~/invoice-check/.env aus Vault (ssh-stdin, nie auf der Kommandozeile)
|
||||||
|
# 2) rsync Code 3) compose up --build 4) Health
|
||||||
|
set -euo pipefail
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
HOST=c-stone-ai-lab@nucbox; DIR=/home/c-stone-ai-lab/invoice-check
|
||||||
|
: "${POSTGRES_PASSWORD:?Vault}" "${SECRET_KEY:?Vault}" "${IMAP_USER:?Vault}" "${IMAP_PASSWORD:?Vault}"
|
||||||
|
ssh "$HOST" "mkdir -p $DIR/rechnungen && umask 077 && cat > $DIR/.env" <<ENV
|
||||||
|
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
|
||||||
|
SECRET_KEY=$SECRET_KEY
|
||||||
|
IMAP_HOST=${IMAP_HOST:-imap.strato.de}
|
||||||
|
IMAP_PORT=${IMAP_PORT:-993}
|
||||||
|
IMAP_USER=$IMAP_USER
|
||||||
|
IMAP_PASSWORD=$IMAP_PASSWORD
|
||||||
|
ENV
|
||||||
|
echo ".env geschrieben"
|
||||||
|
[ "${1:-}" = "--env-only" ] && exit 0
|
||||||
|
rsync -az --delete --exclude __pycache__ --exclude .pytest_cache --exclude node_modules \
|
||||||
|
backend frontend Dockerfile.backend Dockerfile.frontend docker-compose.yml alembic.ini .env.example "$HOST:$DIR/"
|
||||||
|
ssh "$HOST" "cd $DIR && docker compose --env-file .env up -d --build --remove-orphans 2>&1 | tail -3"
|
||||||
|
sleep 5; ssh "$HOST" "curl -sf localhost:8005/health" && echo " → Health OK"
|
||||||
Loading…
Add table
Reference in a new issue