#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT_DIR" if ! command -v docker >/dev/null 2>&1; then echo "[deploy] Docker is required but was not found." exit 1 fi if docker compose version >/dev/null 2>&1; then COMPOSE=(docker compose) elif command -v docker-compose >/dev/null 2>&1; then COMPOSE=(docker-compose) else echo "[deploy] Docker Compose is required but was not found." exit 1 fi if [ ! -f .env.local ]; then cp .env.example .env.local echo "[deploy] Created .env.local from .env.example" echo "[deploy] Real generation requires API keys in .env.local. Empty keys keep mock/local flows available." fi mkdir -p .runtime/data .runtime/uploads .runtime/generated-results if [ -z "${APP_PORT:-}" ] && [ -f .env.local ]; then APP_PORT_FROM_FILE="$(sed -n 's/^APP_PORT=//p' .env.local | tail -n 1)" APP_PORT_FROM_FILE="${APP_PORT_FROM_FILE//\"/}" if [ -n "$APP_PORT_FROM_FILE" ]; then export APP_PORT="$APP_PORT_FROM_FILE" fi fi "${COMPOSE[@]}" up -d --build "${COMPOSE[@]}" ps echo "[deploy] 智念AIGC平台 is starting at http://127.0.0.1:${APP_PORT:-3000}" echo "[deploy] If this is a public server, set NEXT_PUBLIC_APP_URL in .env.local to your domain." echo "[deploy] Web service and zhinian-worker are both managed by Docker Compose."