23 lines
1.1 KiB
Bash
Executable file
23 lines
1.1 KiB
Bash
Executable file
#!/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"
|