Dashboard Settings page always fails to save (EACCES on /.env inside Docker)
Summary (Co-Authored by Claude code)
The dashboard's Settings page always fails to save with "Failed to save settings.
Check backend connection." — but it's not actually a backend/API connectivity issue.
The Next.js API route that handles the save writes to a path that only resolves
correctly in local dev (next dev from a git checkout), not in the Docker deployment
that docker-compose.yml documents as the standard way to run the dashboard.
Root Cause
dashboard/app/api/settings/route.ts:5:
const ENV_PATH = path.resolve(process.cwd(), '../.env')
This assumes process.cwd() is the dashboard/ directory inside a full monorepo
checkout, so ../.env resolves to the repo root's .env. That's true for local dev.
But dashboard/Dockerfile sets WORKDIR /app and copies only the built dashboard
output into the image — there's no monorepo layout inside the container, no sibling
.env one directory up, and /.env (where the path resolves to from /app) doesn't
exist and isn't writable by the non-root nextjs user the container runs as.
Result: any Docker-based deployment (i.e. docker-compose.yml as shipped) gets a
write failure on every settings save attempt, surfaced as a generic backend-connection
error that has nothing to do with the actual cause.
Reproducer
docker compose --profile ui up(per the repo's owndocker-compose.yml)- Open the dashboard → Settings
- Change any field, click "Save to .env"
- Server-side error (visible via
docker compose logs dashboard):[Settings API] write error: Error: EACCES: permission denied, open '/.env' - UI shows: "Failed to save settings. Check backend connection." — misleading, since
the backend (
:8080) was never involved; this route writes directly to a file on the dashboard container's own filesystem.
Suggested Fix
The settings route shouldn't write to a file inside the dashboard container's filesystem at all when running in Docker — that file isn't shared with the backend container and doesn't persist across image rebuilds either way. Options:
- Have the dashboard call the backend server's own config/settings API (if one
exists) instead of writing a local
.env, so the write actually reaches the process that reads it. - If a shared
.envtruly needs editing, mount it as a volume into the dashboard container at a fixed path and reference that path (not a relative../) so it doesn't depend oncwd.
Happy to open a PR if a preferred direction is confirmed.
Environment
- Deployment:
docker compose --profile ui up(repo's own compose file, unmodified aside from a local override for uid/gid and Ollama host networking) - Images built from current
mainvia the repo'sDockerfiles - Dashboard on
:3000, backend on:8080
I will take this issue. Please assign it to me.
The problem is that the ENV_PATH in dashboard/app/api/settings/route.ts resolves incorrectly in the Docker environment. It tries to write to /.env, which is not writable. I would first verify the Docker setup and confirm the path resolution issue. The fix could involve changing the settings route to either call a backend API for configuration changes or mount the .env file as a volume at a fixed path. I will ensure the solution works with the existing Docker setup.
I am still looking into this issue. I will verify the Docker setup and confirm the path resolution problem. Once confirmed, I will work on a solution that either involves calling a backend API for configuration changes or mounting the .env file as a volume. Let me know if there are any preferences or additional insights.
The write path this issue named is gone on current main.
d638f52 (18 Aug) removed ENV_PATH = path.resolve(process.cwd(), '../.env') and the Save to .env UI. dashboard/app/api/settings/route.ts now returns read_only: true on GET and 405 on POST. The Settings page says configuration is read-only and to change env on the backend, then restart.
docker compose --profile ui up on current main cannot hit EACCES on /.env because nothing opens that file.
This can be closed as fixed by the rewrite. If anyone still sees the old save button, they are on a pre-rewrite image.
Closing as fixed — as confirmed in the thread, the write path this issue named (ENV_PATH = path.resolve(process.cwd(), '../.env') in dashboard/app/api/settings/route.ts) was removed in d638f52. The Settings page is now read-only (GET returns read_only: true, POST returns 405) and tells the user to change env on the backend and restart, so there's no /.env write for Docker's non-root user to fail on.
Thanks for the clear root-cause report, and to @modelpath-dev for tracking it down and confirming the fix.