Makefile : make demo et make blank en une commande

- make demo  : db + backend + frontend + jeu de démonstration
- make blank : idem mais édition vierge + 1er compte coordination (params
  surchargeables : EMAIL, PASSWORD, NAME, START, END)
Chaque cible applique les migrations, prépare les données et bascule le
frontend sur l'API réelle (VITE_* dans .env). `make down` / `make logs`.

app/bootstrap.py : commande sous-jacente de `make blank`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
AdamThomas
2026-09-10 21:14:00 +02:00
co-authored by Claude Sonnet 5
parent 6c4297b5fc
commit b894b1d270
2 changed files with 76 additions and 31 deletions
+64
View File
@@ -0,0 +1,64 @@
# Lancement de l'application en une commande.
#
# make demo → base + backend + frontend, jeu de démonstration chargé
# make blank → idem, mais édition vierge + 1er compte coordination
# make down → tout arrêter
# make logs → suivre les logs du backend
#
# `make blank` accepte des paramètres :
# make blank EMAIL=moi@festival.fr PASSWORD=mon-mot-de-passe-solide \
# NAME="Festival 2026" START=2026-07-01 END=2026-07-04
COMPOSE ?= docker compose
PSQL = $(COMPOSE) exec -T db psql -U benevoles -tAc
NAME ?= Mon festival
START ?= 2026-07-01
END ?= 2026-07-04
EMAIL ?= coordination@example.org
PASSWORD ?= changez-ce-mot-de-passe
.PHONY: demo blank down logs help _up _wire-frontend
help:
@sed -n '3,13p' Makefile
demo: _up
$(COMPOSE) run --rm backend uv run python -m app.seed
@$(MAKE) --no-print-directory _wire-frontend
$(COMPOSE) up -d frontend
@echo
@echo "→ http://localhost:5173 (jeu de démonstration)"
@echo " Coordination : coordination@lucioles.test / coordination-lucioles-2026"
blank: _up
$(COMPOSE) run --rm backend uv run python -m app.bootstrap \
--name "$(NAME)" --start "$(START)" --end "$(END)" \
--email "$(EMAIL)" --password "$(PASSWORD)"
@$(MAKE) --no-print-directory _wire-frontend
$(COMPOSE) up -d frontend
@echo
@echo "→ http://localhost:5173 (édition vierge)"
@echo " Connexion : $(EMAIL) / $(PASSWORD)"
down:
$(COMPOSE) down
logs:
$(COMPOSE) logs -f backend
# --- interne -------------------------------------------------------------------
.env:
cp .env.example .env
_up: .env
$(COMPOSE) up -d db backend
$(COMPOSE) run --rm backend uv run alembic upgrade head
# Bascule le frontend sur l'API réelle et pointe sur la dernière édition créée.
_wire-frontend:
@EID=$$($(PSQL) "select id from edition order by created_at desc limit 1" | tr -d '[:space:]'); \
grep -v -E '^(VITE_API_MODE|VITE_EDITION_ID)=' .env > .env.tmp && mv .env.tmp .env; \
printf 'VITE_API_MODE=http\nVITE_EDITION_ID=%s\n' "$$EID" >> .env; \
echo " .env : VITE_API_MODE=http VITE_EDITION_ID=$$EID"