#!/usr/bin/env bash
set -euo pipefail

# Force GPG to use terminal-based pinentry (required for SSH sessions)
export GPG_TTY=$(tty)

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

# Load secrets from gopass
OPENCODE_API_KEY="$(gopass show -o projects/ai-api/opencode_go_key)"

# Start API service only
sudo OPENCODE_API_KEY="$OPENCODE_API_KEY" \
  docker compose -f "$PROJECT_DIR/docker-compose.yml" up api "$@"
