62 lines
2.2 KiB
Bash
Executable File
62 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
if [[ ! -f .env ]]; then
|
|
command -v openssl >/dev/null
|
|
(
|
|
umask 077
|
|
cat > .env <<EOF
|
|
APP_BASE_URL=http://localhost:8088
|
|
VENUE_BIND_IP=127.0.0.1
|
|
VENUE_PORT=8088
|
|
POSTGRES_USER=evening_detective
|
|
POSTGRES_DB=evening_detective
|
|
POSTGRES_PASSWORD=$(openssl rand -hex 32)
|
|
JWT_SECRET=$(openssl rand -hex 32)
|
|
PARTICIPATION_SECRET=$(openssl rand -hex 32)
|
|
S3_USER=evening_detective
|
|
S3_PASSWORD=$(openssl rand -hex 32)
|
|
S3_BUCKET=evening-detective
|
|
GAME_TIMEZONE=Asia/Barnaul
|
|
VENUE_USER_USERNAME=Организатор
|
|
VENUE_USER_EMAIL=organizer@venue.invalid
|
|
VENUE_USER_PASSWORD=$(openssl rand -hex 8)
|
|
EOF
|
|
)
|
|
fi
|
|
|
|
prepare=false
|
|
case "${1:-}" in
|
|
--build) prepare=true ;;
|
|
'') ;;
|
|
*) echo 'Используйте make venue или make venue-update' >&2; exit 1 ;;
|
|
esac
|
|
for image in evening-detective-venue-app:1 postgres:15 rustfs/rustfs:latest byjg/static-httpserver:latest nginx:alpine; do
|
|
if ! docker image inspect "$image" >/dev/null 2>&1; then prepare=true; fi
|
|
done
|
|
for artifact in backend/evening_detective_server backend/goose backend/dev-user.sql frontend/dist/index.html; do
|
|
if [[ ! -f "$artifact" ]]; then prepare=true; fi
|
|
done
|
|
if [[ ! -d migrations ]]; then prepare=true; fi
|
|
if [[ "$prepare" == true ]]; then
|
|
echo 'Подготовка площадки: потребуется интернет.'
|
|
if ! docker image inspect my-go-builder >/dev/null 2>&1; then
|
|
make -C ../evening_detective_server build-builder
|
|
fi
|
|
if [[ ! -d ../evening_detective_frontend/node_modules ]]; then
|
|
npm --prefix ../evening_detective_frontend ci
|
|
fi
|
|
make -C .. build
|
|
docker compose pull postgres_evening_detective_server rustfs_evening_detective_server evening_detective_frontend proxy
|
|
docker pull alpine:3.22
|
|
docker compose build --pull=false
|
|
fi
|
|
for volume in evening-detective-local_postgres_data evening-detective-local_rustfs_data; do
|
|
docker volume create "$volume" >/dev/null
|
|
done
|
|
docker compose up -d --no-build --pull never
|
|
docker compose --profile setup run --rm bootstrap
|
|
docker compose ps
|
|
echo 'Площадка запущена. Адрес и данные входа находятся в venue/.env.'
|