From a5324456ec450189c550d147aa6d7a9e2de42ac5 Mon Sep 17 00:00:00 2001 From: "Ehsan.Asadi" Date: Wed, 31 Dec 2025 03:45:27 +0330 Subject: [PATCH] fix(docker): fix Reflex module path and npm registry | ApprovalToken: 1767140126 - Set PYTHONPATH to /build for Reflex to find app module - Update app_name in rxconfig.py to match actual module path - Configure npm to use registry.npmjs.org instead of mirror - Add fallback from npm ci to npm install on failure - Fixes ModuleNotFoundError: Module peikarband.peikarband not found --- docker/Dockerfile | 7 ++++++- peikarband/rxconfig.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 14f43a7..6781b08 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,6 +49,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # Copy source code COPY peikarband/ . +# Set PYTHONPATH to include /build so Reflex can find the app +ENV PYTHONPATH=/build:$PYTHONPATH + # Initialize Reflex and build frontend RUN reflex init --loglevel debug || true && \ reflex export --frontend-only --no-zip --loglevel debug || echo "Export completed with warnings" @@ -58,12 +61,14 @@ RUN reflex init --loglevel debug || true && \ RUN if [ -d "/build/.web" ] && [ -f "/build/.web/package.json" ]; then \ echo "Found .web directory with package.json, building frontend..." && \ cd /build/.web && \ + npm config set registry https://registry.npmjs.org/ && \ npm config set fetch-retry-mintimeout 20000 && \ npm config set fetch-retry-maxtimeout 120000 && \ npm config set fetch-retries 5 && \ npm config set fetch-timeout 300000 && \ if [ -f "package-lock.json" ]; then \ - npm ci --prefer-offline --no-audit --loglevel verbose; \ + npm ci --prefer-offline --no-audit --loglevel verbose || \ + (echo "npm ci failed, retrying with npm install..." && npm install --prefer-offline --no-audit --loglevel verbose); \ else \ echo "package-lock.json not found, using npm install..." && \ npm install --prefer-offline --no-audit --loglevel verbose; \ diff --git a/peikarband/rxconfig.py b/peikarband/rxconfig.py index 95486f8..3746938 100644 --- a/peikarband/rxconfig.py +++ b/peikarband/rxconfig.py @@ -13,7 +13,7 @@ BACKEND_PORT = int(os.getenv("BACKEND_PORT", "8000")) DB_URL = os.getenv("DATABASE_URL", "sqlite:////app/data/reflex.db") config = rx.Config( - app_name="peikarband", + app_name="src.presentation.web.pages.landing.index", api_url=API_URL, frontend_port=FRONTEND_PORT, backend_port=BACKEND_PORT,