105 lines
2.4 KiB
Bash
105 lines
2.4 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Docker Compose Startup Script for Web Module
|
|
#
|
|
# Usage: ./deploy/deploy.sh [OPTIONS]
|
|
#
|
|
# Options:
|
|
# --profile <api> Docker compose profile (default: api)
|
|
# --detach, -d Run in detached mode
|
|
# --down Stop and remove containers
|
|
# --logs Show logs
|
|
# --help, -h Show this help message
|
|
#
|
|
# Required: Set environment variables in .env file or export them before running.
|
|
# See .env.example for the full list of required variables.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# Load .env file if it exists
|
|
ENV_FILE=""
|
|
if [[ -f "$SCRIPT_DIR/.env" ]]; then
|
|
ENV_FILE="$SCRIPT_DIR/.env"
|
|
elif [[ -f "$SCRIPT_DIR/../.env" ]]; then
|
|
ENV_FILE="$SCRIPT_DIR/../.env"
|
|
fi
|
|
|
|
if [[ -n "$ENV_FILE" ]]; then
|
|
echo "Loading environment from: $ENV_FILE"
|
|
set -a
|
|
source "$ENV_FILE"
|
|
set +a
|
|
fi
|
|
|
|
PROFILE="api"
|
|
DETACH=""
|
|
ACTION="up"
|
|
|
|
show_help() {
|
|
sed -n '2,15p' "$0" | sed 's/^# //' | sed 's/^#//'
|
|
exit 0
|
|
}
|
|
|
|
check_required_var() {
|
|
local var_name="$1"
|
|
if [[ -z "${!var_name:-}" ]]; then
|
|
echo "ERROR: Required environment variable $var_name is not set"
|
|
echo "Set it in .env file or export it before running this script"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Parse arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--profile)
|
|
PROFILE="$2"
|
|
shift 2
|
|
;;
|
|
--detach|-d)
|
|
DETACH="-d"
|
|
shift
|
|
;;
|
|
--down)
|
|
ACTION="down"
|
|
shift
|
|
;;
|
|
--logs)
|
|
ACTION="logs"
|
|
shift
|
|
;;
|
|
--help|-h)
|
|
show_help
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1"
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Check required variables
|
|
check_required_var "WEB_LLM_BASE_URL"
|
|
check_required_var "WEB_EXTERNAL_URL"
|
|
check_required_var "WEB_SEARXNG_BASE_URL"
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
case $ACTION in
|
|
up)
|
|
echo "Starting Web module with profile: $PROFILE"
|
|
echo ""
|
|
# shellcheck disable=SC2086
|
|
exec docker compose --profile "$PROFILE" up $DETACH
|
|
;;
|
|
down)
|
|
echo "Stopping Web module containers..."
|
|
exec docker compose --profile "$PROFILE" down
|
|
;;
|
|
logs)
|
|
exec docker compose --profile "$PROFILE" logs -f
|
|
;;
|
|
esac
|