Files
ai-soulmate-local-deployment/scripts/start-frontend.sh
T

36 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
env_file="${1:-compose/.env}"
compose_file="${BACKEND_COMPOSE_FILE:-compose/docker-compose.backend.yml}"
if [[ ! -r "$env_file" ]]; then
printf 'Environment file not found: %s\n' "$env_file" >&2
exit 1
fi
env_value() {
sed -n "s/^${1}=//p" "$env_file" | head -n 1
}
project_name="$(env_value BACKEND_COMPOSE_PROJECT_NAME)"
frontend_image="$(env_value FRONTEND_IMAGE)"
if [[ -z "$project_name" || "$project_name" == "$(env_value COMPOSE_PROJECT_NAME)" ]]; then
printf 'BACKEND_COMPOSE_PROJECT_NAME must be set and differ from the infrastructure project.\n' >&2
exit 1
fi
if [[ -z "$frontend_image" ]] || ! docker image inspect "$frontend_image" >/dev/null 2>&1; then
printf 'Configured frontend image is not available locally: %s\n' "$frontend_image" >&2
exit 1
fi
compose_command=(
docker compose
--project-name "$project_name"
--env-file "$env_file"
-f "$compose_file"
)
"${compose_command[@]}" config --quiet
"${compose_command[@]}" up -d frontend
"${compose_command[@]}" ps --all