forked from fahrPool/fahrPool
66 lines
3.6 KiB
Markdown
66 lines
3.6 KiB
Markdown
---
|
|
name: rebuild-master-stack
|
|
description: Rebuilds and restarts the docker-compose "web" service with the current master branch code, then verifies it's serving. Run after merging a feature branch into master, or whenever the user asks to see their changes live in the master/production-like stack.
|
|
---
|
|
|
|
# Rebuild Master Stack
|
|
|
|
The user granted standing permission (2026-08-19) to run this proactively after merging a feature branch into master, without asking each time first — it's expected as the normal follow-up to a merge. Still restarts a shared, potentially-in-use service, so use judgment: skip it (or check first) if you have reason to think someone is actively using the master stack right now.
|
|
|
|
## Steps
|
|
|
|
1. Confirm you're operating from the main repo checkout (not a worktree), on `master`, with the change you want to deploy already merged there.
|
|
|
|
2. Rebuild the `web` image:
|
|
|
|
```bash
|
|
docker compose build web
|
|
```
|
|
|
|
If this is the first rebuild after a task that added new npm dependencies (check `web/package.json` diff against the previous deployed state), the build step already runs `npm install` inside the Docker build — no separate action needed there. But if you're instead testing directly against a local `npm run dev` outside Docker, remember to run `npm install` in `web/` yourself first (new dependencies aren't picked up automatically).
|
|
|
|
3. Restart just the `web` container with the new image:
|
|
|
|
```bash
|
|
docker compose up -d web
|
|
```
|
|
|
|
4. Verify it's actually serving the new code, not a stale cached image:
|
|
|
|
```bash
|
|
sleep 3
|
|
curl -s -o /dev/null -w "Status: %{http_code}\n" http://localhost:3001/login
|
|
docker exec aushilfsfahrer-web-1 sh -c "ls /app/.next/server/app/<new-route-added-by-this-change> 2>&1"
|
|
```
|
|
|
|
Pick a route that's specific to whatever just shipped (e.g. a new page directory) so you're confirming the *new* build actually landed, not just that *some* build is running.
|
|
|
|
5. If the merge included new Supabase migrations, apply them to the master stack's database too — it does **not** share a database with the local Supabase CLI dev stack (see the `supabase-local-dev` skill). Check which migrations are missing:
|
|
|
|
```bash
|
|
docker exec -i aushilfsfahrer-db-1 psql -U postgres -d postgres -c "select version from supabase_migrations.schema_migrations order by version;"
|
|
```
|
|
|
|
Apply any missing migration files directly and record them:
|
|
|
|
```bash
|
|
docker exec -i aushilfsfahrer-db-1 psql -U postgres -d postgres -v ON_ERROR_STOP=1 < supabase/migrations/<file>.sql
|
|
docker exec -i aushilfsfahrer-db-1 psql -U postgres -d postgres -c "insert into supabase_migrations.schema_migrations (version) values ('<version>') on conflict (version) do nothing;"
|
|
```
|
|
|
|
Enthielten die neuen Migrationen einen `pg_cron`-Job, der die App aufruft
|
|
(z.B. `notification-dispatch`), zusätzlich die beiden DB-Settings setzen, die
|
|
die Migration bewusst nicht enthält:
|
|
|
|
```bash
|
|
docker exec -i aushilfsfahrer-db-1 psql -U postgres -d postgres -c \
|
|
"alter database postgres set app.notification_dispatch_url = 'http://web:3000/api/notifications/dispatch';"
|
|
docker exec -i aushilfsfahrer-db-1 psql -U postgres -d postgres -c \
|
|
"alter database postgres set app.notification_dispatch_secret = '<Wert von NOTIFICATION_DISPATCH_SECRET aus der Root-.env>';"
|
|
```
|
|
|
|
Danach greifen neue Verbindungen die Settings auf; der Cron-Job ruft ab der
|
|
nächsten Minute `POST /api/notifications/dispatch` auf.
|
|
|
|
Report the admin login URL/credentials back to the user once verified (`admin@aushilfsfahrer.local` / `Admin123!`, or the current password — see the `supabase-local-dev` skill if it's been reset).
|