frontend 이미지는 nginx 공식 이미지라 root로 시작해 80번을 열고 worker를
nginx 사용자로 내린다. 그래서 Kubernetes에서 runAsNonRoot와 drop ALL을 둘
수 없다(k3s 성숙도 점검 2026-11-11, 7.5절). 운영 매니페스트는
allowPrivilegeEscalation: false만 두고 PSA restricted 경고를 낸다.
runtime base를 nginxinc/nginx-unprivileged:1.27.5-alpine(digest 고정)으로
바꾼다. 예전 base와 같은 NGINX 1.27.5·Alpine이고 wget도 있어 HEALTHCHECK가
그대로 돈다. 파일을 고치는 동안만 root로 있다가 USER 101로 돌아간다.
생성되는 server 블록은 listen 8080이고, EXPOSE·HEALTHCHECK·dev-stack 포트
매핑도 8080으로 맞춘다.
버린 대안: Debian판 nginx-unprivileged. wget이 없어 HEALTHCHECK가 늘
실패한다. 80번을 그대로 두고 NET_BIND_SERVICE만 남기는 안도 버렸다.
drop ALL을 못 하고 PSA restricted도 통과하지 못한다.
위험·한계: 이 이미지는 8080을 열므로 운영 매니페스트의 포트를 같이
바꿔야 한다. deploy/production/frontend-nonroot가 그 일을 하고, 기본
경로에는 넣지 않는다. dev-stack의 443·/etc/nginx/tls 부분은 이미지에 없는
파일을 쓰는 예전 상태 그대로다. 이 repo의 pnpm 게이트와 전체 docker
build는 돌리지 않았다(heavy lock 대기가 길어 취소).
검증: desktop에서 이 Dockerfile의 runtime 단계를 그대로 쓰고, 빌드
단계만 운영 이미지 7a4e201의 dist와 conf(listen 8080으로 바꿈)로 대신해
이미지를 만들었다. --user 101 --cap-drop ALL --security-opt
no-new-privileges --sysctl net.ipv4.ip_unprivileged_port_start=1024로
띄우면 GET /config.json 200, GET / 200, CapEff 0, NoNewPrivs 1이고,
Docker health는 healthy다.
The repository had no container image and no production-shaped serving
configuration. `dist/server.mjs` is a preview server that applies neither
the security headers nor the cache policy `config/hosting/` declares, so a
deployment had nothing correct to run.
`scripts/generate-nginx-config.ts` derives the server block from
`dist/tech-log-serving-contract.json` plus the two hosting policy files, so
the served headers and cache lifetimes cannot drift from what the contract
declares. It emits no TLS and no proxy blocks: the edge terminates TLS and
routes /api, and baking a backend address into the image would tie the
bundle to one deployment. Static surfaces use `alias` because a base-path
build serves /dev/assets/... out of dist/assets/..., which `root` plus URI
would look for one directory too deep.
The image copies that config next to the bundle and normalises permissions:
the build writes config.json 0600, which nginx cannot read, so the container
came up healthy and answered 403 for the one file the SPA needs to boot.
index.html never referenced public/favicon.svg. The file shipped and nginx
served it, but browsers asked for /favicon.ico, got a 404, and fell back to
the default icon. `%BASE_URL%` rather than an absolute path so a prefixed
deployment points at its own copy.
development.json moves to the HTTP Studio source; the mock source has no
backend to authenticate against, which is the whole point of that profile.