diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..57b91b7 --- /dev/null +++ b/Makefile @@ -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" diff --git a/README.md b/README.md index c20c573..6803b39 100644 --- a/README.md +++ b/README.md @@ -10,46 +10,27 @@ et les conventions. ## Démarrage rapide ```bash -cp .env.example .env -docker compose up --build +make demo # base + backend + frontend, jeu de démonstration chargé +make blank # idem, mais édition vierge + 1er compte coordination ``` - Frontend : http://localhost:5173 -- API : http://localhost:8000 -- Documentation interactive : http://localhost:8000/docs +- API : http://localhost:8000 · Docs : http://localhost:8000/docs +- `make down` arrête tout · `make logs` suit les logs du backend -Le frontend démarre en mode `mock` (jeu de démonstration en mémoire, aucun -backend requis). +Chaque commande construit les images, applique les migrations, prépare les +données, bascule le frontend sur l'API réelle (`.env`) et affiche les +identifiants de connexion. -### Vraie instance, sans jeu de démo +**`make blank`** accepte des paramètres : ```bash -docker compose up -d db backend -docker compose run --rm backend uv run alembic upgrade head -docker compose run --rm backend uv run python -m app.bootstrap \ - --name "Festival 2026" --start 2026-07-01 --end 2026-07-04 \ - --email coordination@monfestival.fr --password "un-mot-de-passe-solide" +make blank EMAIL=moi@festival.fr PASSWORD=mon-mot-de-passe-solide \ + NAME="Festival 2026" START=2026-07-01 END=2026-07-04 ``` -La commande crée une édition vierge, le premier compte coordination (connexion -par mot de passe) et 3 créneaux types par défaut, puis affiche l'UUID de -l'édition. Renseigner alors dans `.env` : - -``` -VITE_API_MODE=http -VITE_EDITION_ID= -``` - -puis `docker compose up frontend`. - -### Jeu de démonstration (optionnel) - -```bash -docker compose run --rm backend uv run python -m app.seed -``` - -120 bénévoles fictifs, 15 postes, 4 jours. Identifiants affichés en fin de -commande. +Le jeu de démo : 120 bénévoles fictifs, 15 postes, 4 jours. L'édition vierge : +une édition + un compte coordination (mot de passe) + 3 créneaux types. ## Tests