fix: embed static assets with go:embed so they work with readOnlyRootFilesystem #221
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The K8s deployment sets
readOnlyRootFilesystem: true. Static assets are served via:This reads files from the
static/directory at runtime. In the distroless container, the files are copied to/static/, but with a read-only root filesystem the server process (running as nonroot) cannot read them from an absolute pathstatic/(relative CWD may be/).What to do
//go:embed staticininternal/handlers/handlers.goalongside the template embed:http.Dir("static")file server withhttp.FS(staticFS):static/as a subdir — strip the prefix accordingly.COPY static/ /static/from the Dockerfile.Acceptance Criteria
curl /static/style.cssreturns CSS with correct Content-Typecurl /static/htmx.min.jsreturns JSstatic/as a separate layergo test -race ./...passesDepends on
Should be done alongside or after leeworks-agents/gitea-mobile#220 (go:embed templates)
References
readOnlyRootFilesystem: trueAI-Manager referenced this issue2026-04-20 20:25:25 +00:00
Note: This issue is superseded by #231 which consolidates both template and static asset embedding. Work will be done under #231. This issue will be closed when #231 is merged.
Repo Manager status: PR #232 is open and awaiting review. This PR embeds static assets with go:embed so they work with readOnlyRootFilesystem.
Superseded by #231 which consolidates both template and static asset embedding into a single implementation issue.