Automates the full first-time setup in one command (also safe to re-run): - Checks docker/pnpm; installs just if missing - Adds 127.0.0.1 keycloak to /etc/hosts (sudo) - Generates .env with dev JWT tokens computed from the dev secret - Fixes supabase/migrations permissions if root-owned - Starts the Docker stack and waits for postgres/kong/keycloak - Applies SQL migrations with tracking table (won't re-apply) - Seeds the database (no-op if already seeded) - Compiles Paraglide i18n output Also adds `just setup` recipe and fixes the dev anon key in .env.development. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
107 lines
3.6 KiB
Makefile
107 lines
3.6 KiB
Makefile
# Colectivo — task runner
|
|
# Requires: just, docker, pnpm
|
|
|
|
set dotenv-load := true
|
|
|
|
# Alias: docker compose with correct project root so .env is always found
|
|
dc_dev := "docker compose --env-file .env -f infra/docker-compose.dev.yml"
|
|
dc_prod := "docker compose --env-file .env -f infra/docker-compose.prod.yml"
|
|
|
|
# ── Setup ─────────────────────────────────────────────────────────────────────
|
|
|
|
# First-time (and idempotent) local environment setup
|
|
setup:
|
|
bash setup.sh
|
|
|
|
# ── Dev ───────────────────────────────────────────────────────────────────────
|
|
|
|
# Start full local stack (Docker services + SvelteKit dev server)
|
|
dev:
|
|
{{dc_dev}} up -d
|
|
pnpm --filter @colectivo/web dev
|
|
|
|
# Stop local Docker stack
|
|
dev-stop:
|
|
{{dc_dev}} down
|
|
|
|
# Stop and remove all volumes (full reset)
|
|
dev-clean:
|
|
{{dc_dev}} down -v
|
|
|
|
# ── Database ──────────────────────────────────────────────────────────────────
|
|
|
|
# Drop, migrate, and seed the dev database
|
|
db-reset:
|
|
supabase db reset
|
|
|
|
# Apply pending migrations
|
|
db-migrate:
|
|
supabase db push
|
|
|
|
# Apply dev seed data
|
|
db-seed:
|
|
docker exec -i colectivo-dev-db-1 psql -U postgres < supabase/seed.sql
|
|
|
|
# Regenerate TypeScript types from Supabase schema
|
|
db-types:
|
|
supabase gen types typescript --local > packages/types/src/database.ts
|
|
echo "Types written to packages/types/src/database.ts"
|
|
|
|
# Open Supabase Studio
|
|
db-open:
|
|
open http://localhost:54323
|
|
|
|
# ── Keycloak ──────────────────────────────────────────────────────────────────
|
|
|
|
# Export Keycloak realm to keycloak/realm-export.json
|
|
kc-export:
|
|
{{dc_dev}} exec keycloak \
|
|
/opt/keycloak/bin/kc.sh export \
|
|
--realm colectivo \
|
|
--users realm_file \
|
|
--file /tmp/realm-export.json
|
|
{{dc_dev}} cp keycloak:/tmp/realm-export.json keycloak/realm-export.json
|
|
echo "Exported to keycloak/realm-export.json"
|
|
|
|
# Open Keycloak Admin Console
|
|
kc-open:
|
|
open http://localhost:8080/admin
|
|
|
|
# ── Build ─────────────────────────────────────────────────────────────────────
|
|
|
|
# Build all packages
|
|
build:
|
|
pnpm turbo run build
|
|
|
|
# Type-check all packages
|
|
check:
|
|
pnpm turbo run check
|
|
|
|
# Lint all packages
|
|
lint:
|
|
pnpm turbo run lint
|
|
|
|
# Run tests
|
|
test:
|
|
pnpm turbo run test
|
|
|
|
# ── Backup & Restore ──────────────────────────────────────────────────────────
|
|
|
|
# Take a manual backup of a service (e.g. just backup supabase)
|
|
backup service:
|
|
infra/scripts/backup.sh {{service}}
|
|
|
|
# Restore a backup file (e.g. just restore supabase backups/2024-01-01.dump)
|
|
restore service file:
|
|
infra/scripts/restore.sh {{service}} {{file}}
|
|
|
|
# ── Production ────────────────────────────────────────────────────────────────
|
|
|
|
# Deploy to production via SSH
|
|
deploy:
|
|
infra/scripts/deploy.sh
|
|
|
|
# Stream production Docker logs
|
|
logs:
|
|
{{dc_prod}} logs -f
|