fix(docker): fix Reflex module path and npm registry | ApprovalToken: 1767140126
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- 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
This commit is contained in:
Ehsan.Asadi
2025-12-31 03:45:27 +03:30
parent 293096ca13
commit a5324456ec
2 changed files with 7 additions and 2 deletions

View File

@@ -49,6 +49,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \
# Copy source code # Copy source code
COPY peikarband/ . COPY peikarband/ .
# Set PYTHONPATH to include /build so Reflex can find the app
ENV PYTHONPATH=/build:$PYTHONPATH
# Initialize Reflex and build frontend # Initialize Reflex and build frontend
RUN reflex init --loglevel debug || true && \ RUN reflex init --loglevel debug || true && \
reflex export --frontend-only --no-zip --loglevel debug || echo "Export completed with warnings" 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 \ RUN if [ -d "/build/.web" ] && [ -f "/build/.web/package.json" ]; then \
echo "Found .web directory with package.json, building frontend..." && \ echo "Found .web directory with package.json, building frontend..." && \
cd /build/.web && \ cd /build/.web && \
npm config set registry https://registry.npmjs.org/ && \
npm config set fetch-retry-mintimeout 20000 && \ npm config set fetch-retry-mintimeout 20000 && \
npm config set fetch-retry-maxtimeout 120000 && \ npm config set fetch-retry-maxtimeout 120000 && \
npm config set fetch-retries 5 && \ npm config set fetch-retries 5 && \
npm config set fetch-timeout 300000 && \ npm config set fetch-timeout 300000 && \
if [ -f "package-lock.json" ]; then \ 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 \ else \
echo "package-lock.json not found, using npm install..." && \ echo "package-lock.json not found, using npm install..." && \
npm install --prefer-offline --no-audit --loglevel verbose; \ npm install --prefer-offline --no-audit --loglevel verbose; \

View File

@@ -13,7 +13,7 @@ BACKEND_PORT = int(os.getenv("BACKEND_PORT", "8000"))
DB_URL = os.getenv("DATABASE_URL", "sqlite:////app/data/reflex.db") DB_URL = os.getenv("DATABASE_URL", "sqlite:////app/data/reflex.db")
config = rx.Config( config = rx.Config(
app_name="peikarband", app_name="src.presentation.web.pages.landing.index",
api_url=API_URL, api_url=API_URL,
frontend_port=FRONTEND_PORT, frontend_port=FRONTEND_PORT,
backend_port=BACKEND_PORT, backend_port=BACKEND_PORT,