From 334ef4e00cca535680b9d746ce783a352c57af12 Mon Sep 17 00:00:00 2001 From: Macky Date: Fri, 7 Aug 2026 20:20:42 +0700 Subject: [PATCH] fix(Docker): require persistent DATA_DIR volume; add VOLUME + README data-persistence warning Root cause of re-login failing after first-run setup: on EasyPanel/w/o a volume, the container's /app/backend/data (users, incl. the changed admin password) is wiped on every recreate, so logging back in with the new password fails. Added: - ENV DATA_DIR=/app/backend/data (explicit) + VOLUME declaration in Dockerfile - README 'Data persistence' section: must mount a persistent volume to /app/backend/data Verified: backend + live server login>setup>relogin-with-new-password works (200); the failure is deployment data persistence, not login logic. --- Dockerfile | 6 ++++++ README.md | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/Dockerfile b/Dockerfile index c63318f..5c28c01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,12 @@ COPY backend/ ./backend/ # Run WORKDIR /app/backend +# Explicit data dir so operators mount a persistent volume here. +# Without a volume, ALL user data (incl. the admin password change from first-run +# setup) is lost on every container recreate -> re-login with the new password fails. +# Persist with: docker run -v ./data:/app/backend/data (or compose ./data) +ENV DATA_DIR=/app/backend/data ENV FLASK_DEBUG=0 EXPOSE 5001 +VOLUME ["/app/backend/data"] CMD ["python", "run.py"] diff --git a/README.md b/README.md index a6d9afd..a0b0db5 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,14 @@ Real-model verification requires a live `LLM_API_KEY` in `.env`. | super_admin | `admin` | `1234` (forced to set email + change on first login) | Admins create additional users (users/login has no self-registration). + +## ⚠️ Data persistence (IMPORTANT) +All data (users, passwords, groups, sessions) lives in `DATA_DIR` (default `/app/backend/data`). +**This directory MUST be a persistent volume in production.** If the container restarts/recreates +without a volume, all data is wiped — including the admin password you changed on first login, so +you will not be able to log back in with your new password. + +- Docker run: `-v ./data:/app/backend/data` +- Docker Compose: already mounts `./data:/app/backend/data` (see `docker-compose.yml`) +- EasyPanel / other platforms: **mount a persistent volume to `/app/backend/data`** (or point + `DATA_DIR` at a mounted path), otherwise user data resets on every deploy.