fix(docker): remove npm run build and fix PYTHONPATH | ApprovalToken: 1767140602
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Remove npm run build (reflex export already builds frontend)
- Fix PYTHONPATH ENV to avoid undefined variable warning
- Only install npm dependencies, don't run build script
- Fixes 'Missing script: build' error
This commit is contained in:
Ehsan.Asadi
2025-12-31 03:53:22 +03:30
parent ad5c43087a
commit 12aba3df78

View File

@@ -50,16 +50,16 @@ RUN --mount=type=cache,target=/root/.cache/pip \
COPY peikarband/ . COPY peikarband/ .
# Set PYTHONPATH to include /build so Reflex can find the app # Set PYTHONPATH to include /build so Reflex can find the app
ENV PYTHONPATH=/build:$PYTHONPATH ENV PYTHONPATH=/build
# 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"
# Build frontend with npm (fallback if reflex export fails) # Install npm dependencies if .web directory exists
# Check if .web directory exists and has package.json # Note: reflex export already builds the frontend, we just need to install deps
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, installing dependencies..." && \
cd /build/.web && \ cd /build/.web && \
# Remove any existing .npmrc that might override registry # Remove any existing .npmrc that might override registry
rm -f .npmrc && \ rm -f .npmrc && \
@@ -71,6 +71,7 @@ RUN if [ -d "/build/.web" ] && [ -f "/build/.web/package.json" ]; then \
npm config set fetch-timeout 300000 && \ npm config set fetch-timeout 300000 && \
# Verify registry is set correctly # Verify registry is set correctly
echo "Using npm registry: $(npm config get registry)" && \ echo "Using npm registry: $(npm config get registry)" && \
# Install dependencies (reflex export already built the frontend)
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); \ (echo "npm ci failed, retrying with npm install..." && npm install --prefer-offline --no-audit --loglevel verbose); \
@@ -78,9 +79,9 @@ RUN if [ -d "/build/.web" ] && [ -f "/build/.web/package.json" ]; then \
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; \
fi && \ fi && \
npm run build; \ echo "Dependencies installed successfully"; \
else \ else \
echo "Warning: .web directory or package.json not found, skipping npm build"; \ echo "Warning: .web directory or package.json not found, skipping npm install"; \
fi fi
# ============================================ # ============================================