Skip to content

fix(docker): chown /app workdir so Chainlit can write .files#6

Merged
heitor-am merged 1 commit into
mainfrom
fix/dockerfile-permissions
Apr 19, 2026
Merged

fix(docker): chown /app workdir so Chainlit can write .files#6
heitor-am merged 1 commit into
mainfrom
fix/dockerfile-permissions

Conversation

@heitor-am

Copy link
Copy Markdown
Owner

Summary

First Fly deploy crashed at startup with:

PermissionError: [Errno 13] Permission denied: '/app/.files'

WORKDIR /app creates the directory as root before COPY runs; COPY --chown=app:app only sets ownership on files it copies, not on the pre-existing parent dir. At startup Chainlit calls FILES_DIRECTORY.mkdir(exist_ok=True) (resolves to /app/.files) which fails because the workdir is still root-owned when we drop to the app user.

Fix: explicit chown app:app /app after the COPY, before USER switches.

Test plan

  • Verified the failing log on Fly (linked above)
  • uv run ruff check . / format --check — passes (Dockerfile only)
  • Post-merge: deploy workflow rebuilds and the machine becomes healthy

WORKDIR /app creates the directory as root before COPY runs, and
COPY --chown only sets ownership on the files it copies — not on
the pre-existing parent. At startup Chainlit calls
FILES_DIRECTORY.mkdir(exist_ok=True) which expands to /app/.files
and fails with PermissionError because /app is still root-owned
when we drop to the `app` user.

Adds an explicit `chown app:app /app` after the COPY, before USER
switches. Verified by reading the failing log on Fly:
  PermissionError: [Errno 13] Permission denied: '/app/.files'
@heitor-am heitor-am merged commit cb2518e into main Apr 19, 2026
4 checks passed
@heitor-am heitor-am deleted the fix/dockerfile-permissions branch April 19, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant