Skip to content

Commit b6fcc04

Browse files
authored
Merge pull request #45 from os2display/feature/upgrade-guide-align-env-migrate
docs: align 3.x upgrade guide with the shipped 1.x env_migrate task
2 parents dbb6d09 + 8077287 commit b6fcc04

4 files changed

Lines changed: 65 additions & 63 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ 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` 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.
25+
- `task env:migrate` refines the `.env.symfony.migrated` that the 1.x `task env_migrate`
26+
produces via the 2.8 API's `app:utils:convert-env-to-3x` — splitting off the infrastructure
27+
advisory — and falls back to the sed rewrite of a 1.x `.env.docker.local` otherwise.
2928
- Per-service `.env.<svc>.local` override layer for site-specific tuning; gitignored.
3029
- Compose profiles (`COMPOSE_PROFILES=mariadb,traefik`) gate built-in services — drop
3130
`mariadb` for an external DB, drop `traefik` for an external proxy.
@@ -48,7 +47,7 @@ See the [v2.x.x — Skipped](#v2xx---skipped) entry below for why this major ski
4847
- The mariadb service sets `stop_grace_period: 1m`, so the engine gets room for a clean shutdown
4948
instead of being SIGKILLed mid-flush by the 10s default — important right before a major bump.
5049
- `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
50+
running 1.x configuration (`task env_migrate`) *before* the stack is stopped, converter-first
5251
env migration with the sed rename demoted to a fallback, MariaDB auto-upgrade and data-volume
5352
continuity notes, and the `rm docker-compose.yml` step needed before `git checkout`.
5453
- New MariaDB diagnostics: `task db:metrics`, `db:processes`, `db:errors`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ Lifecycle
12501250
Bootstrap and env-file tooling
12511251
env:init Bootstrap .env.symfony from the API image
12521252
env:diff Compare .env.symfony against the image's shipped example
1253-
env:migrate Stage .env.symfony.migrated from env.3x (preferred) or a 1.x .env.docker.local
1253+
env:migrate Refine the 1.x 'task env_migrate' output, or convert a 1.x .env.docker.local
12541254
env:traefik Interactive .env.traefik setup (alias: traefik_env)
12551255
12561256
Operations

Taskfile.yml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -285,33 +285,35 @@ tasks:
285285
rm -f "$tmp"
286286
287287
env:migrate:
288-
desc: Stage a 3.x-shaped .env.symfony.migrated — from env.3x (preferred) or a 1.x .env.docker.local
288+
desc: Stage a 3.x-shaped .env.symfony.migrated — refine the one from 1.x 'task env_migrate', or convert a 1.x .env.docker.local
289289
cmds:
290290
- |
291291
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
292+
ADVISORY=.env.symfony.infra-advisory
293+
294+
# Preferred path: .env.symfony.migrated produced on the 1.x stack by
295+
# `task env_migrate` (the API's app:utils:convert-env-to-3x command),
296+
# carried across the branch switch (it is gitignored on both branches).
297+
# It already carries the loaded values under their 3.x names AND the
298+
# admin/client config.json conversion the sed path below can't see — so
299+
# all that's left is to split the trailing infrastructure-advisory
300+
# comment block (COMPOSE_*/PHP_*/NGINX_*/MARIADB_* notes) out of it.
301+
# Done in place: input and output are the same file.
302+
if [ -f "$OUT" ]; then
303+
echo "Found $OUT from the 1.x 'task env_migrate' — splitting the infra advisory."
304+
# The advisory is a trailing block the converter introduces with a
305+
# fixed marker line; everything above it is the application env. Split
306+
# at the marker: app env stays in $OUT, the advisory goes to its own
307+
# file (surfaced below, not buried in the app env). Re-running is a
308+
# no-op once the advisory has already been removed.
308309
rm -f "$ADVISORY"
310+
TMP=$(mktemp "${OUT}.XXXXXX")
309311
awk -v adv="$ADVISORY" '
310312
/^# The following loaded variables are NOT read/ { infra = 1 }
311313
infra { print > adv; next }
312314
{ print }
313-
' env.3x > "$OUT"
314-
echo "Wrote $OUT (from env.3x)."
315+
' "$OUT" > "$TMP"
316+
mv "$TMP" "$OUT"
315317
if [ -s "$ADVISORY" ]; then
316318
echo ""
317319
echo "Infrastructure variables were split into $ADVISORY."
@@ -321,28 +323,28 @@ tasks:
321323
echo " NGINX_* -> .env.nginx MARIADB_* -> .env.mariadb"
322324
fi
323325
echo ""
324-
echo "Review with: diff -u env.3x $OUT"
325-
echo "Apply with: mv $OUT .env.symfony"
326+
echo "Review $OUT, then apply with: mv $OUT .env.symfony"
326327
echo ""
327328
echo "Still set by hand: DATABASE_URL serverVersion=11.4.10-MariaDB"
328-
echo "(after the MariaDB upgrade — see UPGRADE.md step 6)."
329+
echo "(after the MariaDB upgrade — see UPGRADE.md step 4)."
329330
exit 0
330331
fi
331332
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.
333+
# Fallback path: no .env.symfony.migrated (the 1.x install predated the
334+
# converter, or the stack was already down). Convert a 1.x
335+
# .env.docker.local by sed — an APP_ strip plus the per-site renames the
336+
# converter would do.
335337
if [ -f .env.docker.local ]; then
336338
SRC=.env.docker.local
337339
elif [ -f .env.local ]; then
338340
SRC=.env.local
339341
else
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."
342+
echo "Error: no .env.symfony.migrated, .env.docker.local or .env.local found."
343+
echo "On the 1.x stack, prefer 'task env_migrate' to produce .env.symfony.migrated."
342344
exit 1
343345
fi
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 "No .env.symfony.migrated found — falling back to the sed conversion of $SRC."
347+
echo "(Producing .env.symfony.migrated with 'task env_migrate' on 1.x is preferred:"
346348
echo " it also converts the admin/client config.json, which sed can't.)"
347349
echo ""
348350
# Strip APP_ prefix from every key EXCEPT the framework-defined trio

UPGRADE.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ The full breaking-change list is in [CHANGELOG.md](CHANGELOG.md) under
4646
- **Symfony env vars lose the `APP_` prefix** (except `APP_ENV` and `APP_SECRET`, which Symfony
4747
defines). `APP_DATABASE_URL` becomes `DATABASE_URL`, `APP_JWT_PASSPHRASE` becomes
4848
`JWT_PASSPHRASE`, etc. The 2.8 API ships `app:utils:convert-env-to-3x`, which does the rename
49-
for you (and converts the admin/client `config.json`) — this repo's `task upgrade_prep` runs
50-
it; see the pre-upgrade checklist below.
49+
for you (and converts the admin/client `config.json`) — this repo's `task env_migrate` (on the
50+
1.x branch) runs it; see the pre-upgrade checklist below.
5151
- **One env file per service.** The single `.env.docker.local` is gone, replaced by
5252
`.env.symfony` + `.env.php` + `.env.nginx` + `.env.mariadb` + `.env.traefik` + the
5353
compose-orchestration `.env`. See [README § Configuration files](README.md#configuration-files).
@@ -63,7 +63,7 @@ The full breaking-change list is in [CHANGELOG.md](CHANGELOG.md) under
6363
### Pre-upgrade checklist (while still on 1.x)
6464

6565
Everything in this section runs on the **1.x** checkout, with the stack **still up**. The
66-
configuration export (`task upgrade_prep`) reads the running application and fetches the live
66+
configuration export (`task env_migrate`) reads the running application and fetches the live
6767
admin/client `config.json` — it cannot run once the stack is stopped. Confirm prerequisites
6868
first:
6969

@@ -84,29 +84,30 @@ Then, on the 1.x stack:
8484
- [ ] **Be on the final 1.x release running 2.8 API images.** The export command ships with
8585
`os2display-api-service` 2.8.0. Set `COMPOSE_VERSION_API=2.8.0` (or a later 2.x) in
8686
`.env.docker.local` and `task install` to pull and recreate. The last 1.x release of this repo
87-
(v1.2.0) provides `task upgrade_check` / `task upgrade_prep`; upgrade to it first if you are on
87+
(v1.2.0) provides `task upgrade_check` / `task env_migrate`; upgrade to it first if you are on
8888
an earlier 1.x.
8989
- [ ] **Run the pre-flight check:** `task upgrade_check`. It confirms the api image provides
9090
`app:utils:convert-env-to-3x` and prints the bundled MariaDB volume name
9191
(`<COMPOSE_PROJECT_NAME>_mariadb`). **Record that volume name** — the 3.x stack reuses it in
9292
place, and only does so when the 3.x `.env` keeps the same `COMPOSE_PROJECT_NAME`. A different
9393
project name silently boots an *empty* database (see step 4).
9494
- [ ] **Back up the database:** `task backup_db` (1.x), and keep the dump somewhere off-host.
95-
- [ ] **Export the configuration in 3.x shape:** `task upgrade_prep`. It writes `env.3x` — the
96-
loaded env converted to 3.x names *plus* the admin/client `config.json` conversion. The
97-
trailing advisory block lists infrastructure variables (`COMPOSE_*`, `PHP_*`, `NGINX_*`,
98-
`MARIADB_*`) that move to per-service files in 3.x, never into the application env.
95+
- [ ] **Export the configuration in 3.x shape:** `task env_migrate` (1.x). It writes
96+
`.env.symfony.migrated` — the loaded env converted to 3.x names *plus* the admin/client
97+
`config.json` conversion. A trailing advisory block lists infrastructure variables
98+
(`COMPOSE_*`, `PHP_*`, `NGINX_*`, `MARIADB_*`) that move to per-service files in 3.x, never
99+
into the application env.
99100
- [ ] **Copy env files + JWT keys aside** in case a rollback is needed:
100101

101102
```bash
102103
mkdir -p /tmp/os2display-1x-backup
103-
cp .env .env.docker.local .env.local env.3x /tmp/os2display-1x-backup/ # whatever subset you have
104+
cp .env .env.docker.local .env.local .env.symfony.migrated /tmp/os2display-1x-backup/ # whatever subset you have
104105
cp -r jwt/ /tmp/os2display-1x-backup/
105106
```
106107

107-
`env.3x` contains every application secret (`APP_SECRET`, database and OIDC credentials, ...). It
108-
is gitignored on both branches; treat it like a credentials file and it will survive the branch
109-
switch in step 2 untouched.
108+
`.env.symfony.migrated` contains every application secret (`APP_SECRET`, database and OIDC
109+
credentials, ...). It is gitignored on both branches; treat it like a credentials file and it
110+
will survive the branch switch in step 2 untouched.
110111

111112
You do **not** need to copy `./media/` aside for the rollback. It's a host bind-mount, not a
112113
docker named volume — `task purge`, `task down --volumes`, and `docker compose down --volumes`
@@ -169,15 +170,15 @@ per-service `env_file:` directives:
169170
| `.env.mariadb` | MariaDB credentials. |
170171
| `.env.traefik` | Traefik dashboard auth, Let's Encrypt email, cert provider. |
171172

172-
Build `.env.symfony` from the `env.3x` you exported in the pre-upgrade checklist, then bootstrap
173-
the rest:
173+
Build `.env.symfony` from the `.env.symfony.migrated` you exported in the pre-upgrade checklist
174+
(it survives the branch switch — gitignored on both branches), then bootstrap the rest:
174175

175176
```bash
176-
# 1. Application config from env.3x. task env:migrate detects env.3x, splits off the
177-
# infrastructure advisory (into .env.symfony.infra-advisory) and writes the rest to
178-
# .env.symfony.migrated for review.
177+
# 1. Application config. task env:migrate finds the .env.symfony.migrated produced by 'task
178+
# env_migrate' on 1.x and splits its trailing infrastructure advisory into
179+
# .env.symfony.infra-advisory, leaving the clean application env in .env.symfony.migrated.
179180
task env:migrate
180-
diff -u env.3x .env.symfony.migrated # sanity check
181+
$EDITOR .env.symfony.migrated # sanity check
181182
mv .env.symfony.migrated .env.symfony
182183

183184
# 2. Per-service files + .env. task env:init creates .env (prompts for the domain) and the
@@ -194,8 +195,8 @@ $EDITOR .env
194195
# 4. Finish .env.symfony.
195196
$EDITOR .env.symfony
196197
# - Set DATABASE_URL serverVersion to "11.4.10-MariaDB" (post-MariaDB upgrade — see step 4).
197-
# env.3x carries the old 10.x serverVersion through verbatim; this is the one value env:migrate
198-
# leaves for you.
198+
# The converter carries the old 10.x serverVersion through verbatim; this is the one value
199+
# env:migrate leaves for you.
199200
# - Distribute the keys from .env.symfony.infra-advisory: COMPOSE_* -> .env, PHP_* -> .env.php,
200201
# NGINX_* -> .env.nginx, MARIADB_* -> .env.mariadb.
201202

@@ -215,17 +216,17 @@ task env:diff
215216
```
216217

217218
<details>
218-
<summary>Manual fallback (no `env.3x` — pre-2.8 images, or stack already stopped)</summary>
219+
<summary>Manual fallback (no `.env.symfony.migrated` — pre-2.8 images, or stack already stopped)</summary>
219220

220-
If you never produced `env.3x` (the 1.x install predates the converter, or the stack is already
221-
down), `task env:migrate` falls back to a sed conversion of `.env.docker.local`: it strips the
222-
`APP_` prefix from every key except the framework-defined trio (`APP_ENV` / `APP_SECRET` /
223-
`APP_DEBUG`) and writes `.env.symfony.migrated`. This path **cannot** see the admin/client
224-
`config.json`, so you also convert those by hand and apply the per-site renames the converter
225-
would have done:
221+
If you never produced `.env.symfony.migrated` (the 1.x install predates the converter, or the
222+
stack was already down), `task env:migrate` falls back to a sed conversion of `.env.docker.local`:
223+
it strips the `APP_` prefix from every key except the framework-defined trio (`APP_ENV` /
224+
`APP_SECRET` / `APP_DEBUG`) and writes `.env.symfony.migrated`. This path **cannot** see the
225+
admin/client `config.json`, so you also convert those by hand and apply the per-site renames the
226+
converter would have done:
226227

227228
```bash
228-
task env:migrate # sed path when env.3x is absent
229+
task env:migrate # sed path when .env.symfony.migrated is absent
229230
diff -u .env.docker.local .env.symfony.migrated
230231
$EDITOR .env.symfony.migrated
231232
```

0 commit comments

Comments
 (0)