BangSo/scripts/start-local.sh

49 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2026-09-01 16:51:19 +00:00
#!/usr/bin/env bash
set -euo pipefail
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_dir"
2026-09-02 07:38:57 +00:00
rebuild_computer=0
for arg in "$@"; do
case "$arg" in
--rebuild-computer) rebuild_computer=1 ;;
*)
echo "Unknown argument: $arg" >&2
exit 2
;;
esac
done
2026-09-01 16:51:19 +00:00
for command_name in docker pnpm; do
if ! command -v "$command_name" >/dev/null 2>&1; then
echo "Missing required command: $command_name" >&2
exit 1
fi
done
2026-09-02 07:38:57 +00:00
bash "$repo_dir/scripts/ensure-local-env.sh"
2026-09-01 16:51:19 +00:00
if [[ ! -f .env ]]; then
2026-09-02 07:38:57 +00:00
echo "Missing .env after local env setup." >&2
2026-09-01 16:51:19 +00:00
exit 1
fi
if ! docker info >/dev/null 2>&1; then
echo "Docker is not running. Start Docker Desktop and try again." >&2
exit 1
fi
pnpm install --frozen-lockfile
docker compose --env-file .env -f infra/compose/docker-compose.yml up postgres -d --wait
pnpm db:generate
pnpm db:migrate
2026-09-02 07:38:57 +00:00
if [[ "$rebuild_computer" -eq 1 ]] || ! docker image inspect rakazo/computer:local >/dev/null 2>&1; then
2026-09-01 16:51:19 +00:00
pnpm sandbox:build
fi
2026-09-01 17:03:28 +00:00
echo "Starting BangSo Bot at http://127.0.0.1:5173"
2026-09-01 16:51:19 +00:00
exec pnpm dev