Skip to content

Commit dbb6d09

Browse files
authored
Merge pull request #44 from os2display/feature/upgrade-guide-convert-env-flow
docs: restructure 1.x → 3.x upgrade around the 2.8 config converter
2 parents 078edc9 + e5c57ea commit dbb6d09

6 files changed

Lines changed: 302 additions & 125 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
# cookbook entry "How do I override env config locally?".
1212
*.local
1313

14+
# 1.x → 3.x migration intermediates, all secret-bearing: env.3x is the
15+
# converter export from `task upgrade_prep` on the 1.x stack; the others are
16+
# produced by `task env:migrate`.
17+
env.3x
18+
.env.symfony.migrated
19+
.env.symfony.infra-advisory
20+
1421
# Operator-generated by `task host:resources` — host-specific resource limits.
1522
compose.resource-limits.yml
1623
.playwright-mcp/

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ See the [v2.x.x — Skipped](#v2xx---skipped) entry below for why this major ski
2222
templates.
2323
- `task env:diff` compares your `.env.symfony` against the example shipped in the
2424
currently-pinned API image.
25-
- `task env:migrate` rewrites a 1.x `.env.docker.local` into the v3 layout.
25+
- `task env:migrate` stages a v3 `.env.symfony` from `env.3x` (the export the 1.x
26+
`task upgrade_prep` produces via the 2.8 API's `app:utils:convert-env-to-3x`) when present —
27+
splitting off the infrastructure advisory — and falls back to the sed rewrite of a 1.x
28+
`.env.docker.local` otherwise.
2629
- Per-service `.env.<svc>.local` override layer for site-specific tuning; gitignored.
2730
- Compose profiles (`COMPOSE_PROFILES=mariadb,traefik`) gate built-in services — drop
2831
`mariadb` for an external DB, drop `traefik` for an external proxy.
@@ -38,6 +41,16 @@ See the [v2.x.x — Skipped](#v2xx---skipped) entry below for why this major ski
3841
— return only when the stack is genuinely ready (no more `sleep 20` race).
3942
- New `task db:backup` (online `mariadb-dump` to `./backup/<ts>.sql.gz`) and `task db:upgrade`
4043
(idempotent `mariadb-upgrade`).
44+
- The mariadb service sets `MARIADB_AUTO_UPGRADE=1`, so `mariadb-upgrade` runs automatically on
45+
the first 11.4 boot against a carried-over 10.x data dir (the 1.x → 3.x case) — no manual
46+
step required for the system-table upgrade. It also refreshes the healthcheck user, rescuing
47+
data dirs old enough to predate it.
48+
- The mariadb service sets `stop_grace_period: 1m`, so the engine gets room for a clean shutdown
49+
instead of being SIGKILLed mid-flush by the 10s default — important right before a major bump.
50+
- `UPGRADE.md` restructured around the 2.8 converter: a pre-upgrade checklist that exports the
51+
running 1.x configuration (`task upgrade_prep`) *before* the stack is stopped, converter-first
52+
env migration with the sed rename demoted to a fallback, MariaDB auto-upgrade and data-volume
53+
continuity notes, and the `rm docker-compose.yml` step needed before `git checkout`.
4154
- New MariaDB diagnostics: `task db:metrics`, `db:processes`, `db:errors`.
4255
- New `task php:opcache` — operator report on the FPM pool's OPcache (memory, interned
4356
strings, cached-key headroom, hit rate, restarts, preload) with warnings mapped to the

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,10 @@ reasoning.
296296
#### How do I upgrade the bundled MariaDB across a major version?
297297

298298
See [UPGRADE.md](UPGRADE.md). The 1.x → 3.x section has the recipe (it covers the 10.x → 11.4
299-
jump that came with the 3.0 release); the same `task db:backup``task db:upgrade`
300-
update `DATABASE_URL` `serverVersion=` flow applies to any future major bump.
299+
jump that came with the 3.0 release). The mariadb service sets `MARIADB_AUTO_UPGRADE=1`, so
300+
`mariadb-upgrade` runs automatically the first time a newer image starts against the existing
301+
data dir; the manual flow for any future major bump is `task db:backup` → bump the image tag →
302+
`task db:upgrade` (explicit, idempotent re-run) → update `DATABASE_URL` `serverVersion=`.
301303

302304
#### How do I switch from Let's Encrypt to a custom certificate?
303305

@@ -1248,7 +1250,7 @@ Lifecycle
12481250
Bootstrap and env-file tooling
12491251
env:init Bootstrap .env.symfony from the API image
12501252
env:diff Compare .env.symfony against the image's shipped example
1251-
env:migrate Convert a 1.x .env.docker.local to .env.symfony.migrated
1253+
env:migrate Stage .env.symfony.migrated from env.3x (preferred) or a 1.x .env.docker.local
12521254
env:traefik Interactive .env.traefik setup (alias: traefik_env)
12531255
12541256
Operations

Taskfile.yml

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,66 @@ tasks:
285285
rm -f "$tmp"
286286
287287
env:migrate:
288-
desc: Convert a 1.x .env.docker.local into a 3.x-shaped .env.symfony.migrated
288+
desc: Stage a 3.x-shaped .env.symfony.migrated — from env.3x (preferred) or a 1.x .env.docker.local
289289
cmds:
290290
- |
291+
OUT=.env.symfony.migrated
292+
293+
# Preferred path: env.3x produced by `task upgrade_prep` on the 1.x
294+
# stack (the API's app:utils:convert-env-to-3x command). It already
295+
# carries the loaded values under their 3.x names AND the admin/client
296+
# config.json conversion the sed path below can't see — so when it's
297+
# present we just split off the trailing infrastructure-advisory
298+
# comment block (COMPOSE_*/PHP_*/NGINX_*/MARIADB_* notes) into a
299+
# reminder, and the rest becomes .env.symfony directly.
300+
if [ -f env.3x ]; then
301+
echo "Found env.3x from the 1.x upgrade prep — using it as the source."
302+
# env.3x ends with a trailing advisory block the converter
303+
# introduces with a fixed marker line; everything above it is the
304+
# application env. Split at the marker: app env to .env.symfony,
305+
# the advisory to its own file (surfaced below, not buried in the
306+
# app env).
307+
ADVISORY=.env.symfony.infra-advisory
308+
rm -f "$ADVISORY"
309+
awk -v adv="$ADVISORY" '
310+
/^# The following loaded variables are NOT read/ { infra = 1 }
311+
infra { print > adv; next }
312+
{ print }
313+
' env.3x > "$OUT"
314+
echo "Wrote $OUT (from env.3x)."
315+
if [ -s "$ADVISORY" ]; then
316+
echo ""
317+
echo "Infrastructure variables were split into $ADVISORY."
318+
echo "They do NOT belong in .env.symfony — distribute them across the"
319+
echo "per-service files of the 3.x layout:"
320+
echo " COMPOSE_* -> .env PHP_* -> .env.php"
321+
echo " NGINX_* -> .env.nginx MARIADB_* -> .env.mariadb"
322+
fi
323+
echo ""
324+
echo "Review with: diff -u env.3x $OUT"
325+
echo "Apply with: mv $OUT .env.symfony"
326+
echo ""
327+
echo "Still set by hand: DATABASE_URL serverVersion=11.4.10-MariaDB"
328+
echo "(after the MariaDB upgrade — see UPGRADE.md step 6)."
329+
exit 0
330+
fi
331+
332+
# Fallback path: no env.3x (older 1.x without the converter command, or
333+
# the stack is already down). Convert a 1.x .env.docker.local by sed —
334+
# an APP_ strip plus the per-site renames the converter would do.
291335
if [ -f .env.docker.local ]; then
292336
SRC=.env.docker.local
293337
elif [ -f .env.local ]; then
294338
SRC=.env.local
295339
else
296-
echo "Error: neither .env.docker.local nor .env.local exists."
340+
echo "Error: no env.3x, .env.docker.local or .env.local found."
341+
echo "On the 1.x stack, prefer 'task upgrade_prep' to produce env.3x."
297342
exit 1
298343
fi
299-
OUT=.env.symfony.migrated
344+
echo "No env.3x found — falling back to the sed conversion of $SRC."
345+
echo "(The env.3x path from 'task upgrade_prep' on 1.x is preferred:"
346+
echo " it also converts the admin/client config.json, which sed can't.)"
347+
echo ""
300348
# Strip APP_ prefix from every key EXCEPT the framework-defined trio
301349
# (APP_ENV, APP_SECRET, APP_DEBUG) — Symfony recognises those by name,
302350
# and renaming them silently breaks env-driven debug/secret/env config.

0 commit comments

Comments
 (0)