gigafibre-fsm/apps/ops/deploy.sh
louispaulb 1ed86e37ad fix: server-side API token injection + ticket modal empty state
- Move ERPNext API token from JS bundle to nginx proxy_set_header
  (token only lives on server, never in client code)
- Switch ops + field apps from auth.targo.ca to id.gigafibre.ca SSO
- Fix "Aucun contenu" showing on tickets that have comments but no
  description (check comments.length in v-if condition)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 23:31:58 -04:00

58 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# ─────────────────────────────────────────────────────────────────────────────
# deploy.sh — Build Targo Ops PWA and deploy to ops-frontend nginx container
#
# The ops app is served by a standalone nginx container (ops-frontend) at
# erp.gigafibre.ca/ops/. Traefik strips /ops prefix before proxying to nginx.
# Authentik protection is handled via Traefik forwardAuth middleware.
#
# Static files go to /opt/ops-app/ on the host, mounted into the container.
#
# Usage:
# ./deploy.sh # deploy to remote server (production)
# ./deploy.sh local # deploy to local Docker (development)
#
# Prerequisites (remote):
# - SSH key ~/.ssh/proxmox_vm for root@96.125.196.67
# - ops-frontend container running (see infra/docker-compose.yaml)
# ─────────────────────────────────────────────────────────────────────────────
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
SERVER="root@96.125.196.67"
SSH_KEY="$HOME/.ssh/proxmox_vm"
DEST="/opt/ops-app"
echo "==> Installing dependencies..."
npm ci --silent
echo "==> Building PWA (base=/ops/)..."
DEPLOY_BASE=/ops/ npx quasar build -m pwa
if [ "$1" = "local" ]; then
# ── Local deploy ──
echo "==> Deploying to local $DEST..."
rm -rf "$DEST"/*
cp -r dist/pwa/* "$DEST/"
echo ""
echo "Done! Targo Ops: http://localhost/ops/"
else
# ── Remote deploy ──
echo "==> Packaging..."
tar czf /tmp/ops-pwa.tar.gz -C dist/pwa .
echo "==> Deploying to $SERVER..."
cat /tmp/ops-pwa.tar.gz | ssh -i "$SSH_KEY" "$SERVER" \
"cat > /tmp/ops.tar.gz && \
rm -rf $DEST/*.js $DEST/*.html $DEST/*.json $DEST/assets $DEST/icons && \
cd $DEST && tar xzf /tmp/ops.tar.gz && \
rm -f /tmp/ops.tar.gz"
rm -f /tmp/ops-pwa.tar.gz
echo ""
echo "Done! Targo Ops: https://erp.gigafibre.ca/ops/"
fi