mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20:40 +07:00
perf(edit): load the draft documents as one concurrent wave
EditModeShell issued the 12 draft documents with a for-loop of awaits, then the 2 category-label files. It now starts two concurrent requests whose success and failure handlers are attached in the same tick, so a label rejection landing while the documents are still in flight is not an unhandled rejection. The two failure branches are unchanged: a document failure is the offline state, a label failure only disables the category rule. Measured through the dev proxy, the same transport the app uses: 12 documents sequential 902 ms -> 210 ms for the whole 14-request wave, 38768 bytes and 12 distinct payloads byte-identical to the sequential loop. nginx.conf now proxies /api/content/ to Gitea over HTTP/2 (proxy_http_version 2 + a cleared Connection header), so the wave rides one pooled upstream connection instead of one HTTP/1.1 connection per in-flight request. The stack's nginx 1.31.x already does HTTP/1.1 with upstream keepalive caching by default since 1.29.7, so no upstream block is declared and the envsubst contract is untouched; the pipeline's test-before-touch nginx -t is what proves the image accepts proxy_http_version 2. Specs: spec-v4-live-edit.md row 25 + the draft-initialization bullet, spec-v4-deploy-infra.md D14 + row 10, AGENTS.md nginx.conf line.
This commit is contained in:
1 parent
3126971852
commit
83da513931
5 files changed
+43
-12
No files matched your search
@@ -35,6 +35,7 @@ Dockge is a UI over compose files on disk: it reads the stack's `compose.yaml` f
|
||||
| D11 | **`GITEA_CONTENTS_API` (full Contents-API base URL, incl. repo path) becomes a runtime configuration value** consumed only by the nginx container and the dev proxy — never CI, never the bundle. Repository literals removed: `nginx.conf` (`proxy_pass ${GITEA_CONTENTS_API};`, rev.6; the `proxy_set_header Host code.vugado.com` line is deleted — nginx's default `$proxy_host` for a literal proxy_pass gives the identical Host header) and `vite.config.ts:19-22` (parse `process.env.GITEA_CONTENTS_API` into proxy target + rewrite prefix; unset → no proxy → edit mode offline, identical to today's no-token behavior). `envsubst` renders at container start **before** nginx parses the config, so the rendered `proxy_pass` is a literal string — no `resolver` needed. Server home: the stack's single config file (D13); local home: the uncommitted local `.env` (vite's standard channel; the dev machine has no Dockge UI). `NGINX_ENVSUBST_FILTER=GITEA_TOKEN|GITEA_CONTENTS_API` stays a plain env var in compose — it names variables to substitute, it is not itself sensitive. [rev.8: the filter is a **regex** the official entrypoint matches against each variable name — alternatives MUST be separated with `|`; the original comma form matched nothing and left the `${…}` tokens in the rendered config.] | The Gitea host + `dong.nguyen/cv` path is infrastructure, not product — today it appears in `nginx.conf:50,52` and `vite.config.ts:19-22`, so the dev proxy drifts from production by hand; after this both read the same value. The URL is public, so its secret-file home is about **placement** (outside the repo, outside the Dockge env tab), not confidentiality. |
|
||||
| D12 | **`SITE_NAME` (the `<title>`/og:title/twitter:title string) also becomes an env value.** The three `index.html` literals become `%SITE_NAME%` tokens filled by the same plugin; `site.ts`'s `siteName` export (currently **dead** — no consumer in the repo) is kept as the config module's typed accessor for the plugin and scripts. Known duplication recorded: the same person string exists in the content dictionaries (`profile.name` + `profile.title`); meta tags are build-time single-language chrome while content is runtime per-language, so v1 accepts the duplication and the env value. A future single-source option (compose the title from the documents at build time) is a follow-up, not part of this change. | Owner chose "Gồm cả siteName" 2026-10-23. Leaving the name in the repo while the URL moves out would half-solve the stated goal. |
|
||||
| D13 | **The stack's runtime config is ONE server-side file, not `.env`, not multiple files** (owner direction 2026-10-23: "don't use .env", "use only one file"). `compose.yaml`: `secrets: [site_config]` with `secrets.site_config.file = ./secrets/site_config` (stack directory, chmod 600, owner-side, gitignored), a dotenv-format file holding exactly `GITEA_TOKEN=…` and `GITEA_CONTENTS_API=…` (shell-safe values: hex token, URL — no spaces/quotes). The entrypoint sources it before the official entrypoint renders: `entrypoint: ["sh", "-c", "set -a; . /run/secrets/site_config; exec /docker-entrypoint.sh nginx -g 'daemon off;'"]` — `set -a` is required (a sourced assignment is a shell variable; without export the entrypoint child and its envsubst step see nothing), and the nginx command is written inline because a compose entrypoint override does not keep the image's CMD (`CMD=[]`; an empty `$@` makes the exec a no-op → exit 0 → restart loop). Both proven by a local run 2026-10-23; the original `$$@` form and its rationale were wrong. The full target file is §4.1. The stack directory has **no `.env` at all**; no sensitive value appears in compose's `environment:`. File-based secrets under plain `docker compose` (non-swarm) were verified on the VPS 2026-10-23. | Env vars appear in plaintext in the Dockge env editor and in `docker inspect`; a sourced secret file appears in neither (only its path is visible). Startup stays unattended: the file is read at container start, no human key (an "encrypted .env + key" scheme would break pipeline/boot recreations, which have no one to type the key). One file = one rotation surface, one rsync exclusion, one drift candidate. The only remaining plaintext is the rendered `default.conf` inside the container's writable layer — never bind-mounted, never on the host. |
|
||||
| D14 | **`/api/content/` proxies to Gitea over HTTP/2** (`proxy_http_version 2` + `proxy_set_header Connection "";`, `nginx.conf:51-60`, 2026-10-24). Measured 2026-10-24: `code.vugado.com` and `cv.vugado.com` both complete an ALPN h2 handshake and answer 200 (`server: openresty`); neither advertises `Alt-Svc`, so HTTP/3 is not offered to browsers and is not pursued. The stack's container is nginx 1.31.6 (owner-confirmed): HTTP/1.1 to upstreams **and** upstream keepalive caching (`keepalive 32 local`) are the defaults since 1.29.7, so connection reuse needs no `upstream` block — the first draft of this change (a named `upstream` + a `${GITEA_HOST}` derived from `GITEA_CONTENTS_API` in the entrypoint) was dropped because it would move the Gitea repo path back into `nginx.conf`, against D11. `proxy_http_version 2` exists since 1.29.4 and requires `ngx_http_v2_module` in the image: if the image lacks it, the test-before-touch `nginx -t` step fails and production is never touched (D3), and the fallback is simply to drop the two lines, since HTTP/1.1 + keepalive is already this container's default behavior. | Pairs with `spec-v4-live-edit.md` row 25: the client now issues its 14 reads as one concurrent wave. Over HTTP/1.1 a concurrent wave costs one upstream connection per in-flight request; over HTTP/2 they are streams on a single pooled connection. |
|
||||
|
||||
Env surface (the whole contract): `SITE_URL` + `SITE_NAME` = Gitea Actions **variables** (`vars.` context) on the `build`/`generate-resume` jobs — revised 2026-10-23: these are public values, so Gitea's variables mechanism is the correct channel (secrets are for sensitive values; masked secrets also made a missing/empty `SITE_URL` undiagnosable in logs); `GITEA_TOKEN` + `GITEA_CONTENTS_API` = the stack's single config file `secrets/site_config` (D13; never in `.env`, never in the repository, never in CI, never in the bundle). Local development: an uncommitted local `.env` (vite's standard channel) carries the runtime values; `.env.example` is committed with all four names (`SITE_URL`, `SITE_NAME`, `GITEA_TOKEN`, `GITEA_CONTENTS_API`) and no values.
|
||||
|
||||
@@ -176,3 +177,4 @@ GITEA_CONTENTS_API=https://<gitea-host>/api/v1/repos/<owner>/<repo>/contents/
|
||||
| 6 | D10–D12 implementation: `site.ts` env read, `index.html` tokens + vite plugin, robots generation, `nginx.conf` variables, `vite.config.ts` env proxy, `deploy.yml` env, `.env.example`, AGENTS.md | ✅ Done 2026-10-23 — verified: `pnpm build` with `.env` filled emits injected meta + `dist/robots.txt`; `SITE_URL=` empty fails with the named-variable error; runtime files grep-clean of `vugado` |
|
||||
| 9 | D13 implementation: `compose.yaml` per §4.1 (secret `site_config` + entrypoint override), `.gitignore` += `secrets/`; VPS: create `secrets/site_config`, delete stack `.env` | 🟡 Repo side Done 2026-10-23, entrypoint corrected the same day (`set -a` + inline nginx command — the `$$@` form restart-looped, proven locally; full local stack verified Up + probe 200); owner-side file + stack `.env` removal TODO |
|
||||
| 7 | Owner-side: Gitea Actions **variables** `SITE_URL`, `SITE_NAME` (rev.: switched from secrets 2026-10-23 — public values belong in the `vars.` context); local `.env` from `.env.example` | 🟡 Local `.env` created 2026-10-23 (values known; `GITEA_TOKEN` left as shell env as before); Gitea variables TODO — owner-side |
|
||||
| 10 | D14 implementation: HTTP/2 upstream for `/api/content/` | ✅ Repo side Done 2026-10-24 — `nginx.conf:51-60` (`proxy_http_version 2` + `proxy_set_header Connection ""`), `proxy_pass ${GITEA_CONTENTS_API}` untouched. The env contract is unchanged: the template still references only `${GITEA_TOKEN}` and `${GITEA_CONTENTS_API}` (grep-verified), so `NGINX_ENVSUBST_FILTER` in `compose.yaml:25` and in the workflow's test step need no edit, and `compose.yaml` / `deploy/htpasswd` are not touched. Not checkable on the dev machine (no nginx binary, Docker daemon off) — the acceptance check is the pipeline's own test-before-touch step plus a live edit-mode load. ⬜ CI: the next `deploy-infra` run — its throwaway `nginx -t` is what proves the image accepts `proxy_http_version 2` (if it does not, D14's fallback is to drop the two lines); then `docker exec dong-site nginx -t` and an edit-mode load on the deployed site |
|
||||
Reference in new issue
Block a user