[FIX] Fix Reflex build errors and improve Docker permissions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Add state_auto_setters=True to rxconfig.py (fixes Reflex 0.8.9+ deprecation) - Fix node_modules/.bin permissions in Dockerfile (both files and symlinks) - Add permission validation in entrypoint.sh - Fix healthcheck endpoint from /_health to /ping on port 8000 - Add diagnostic commands to Dockerfile for debugging - Improve permission handling in builder and runtime stages Fixes permission denied error for react-router during production build
This commit is contained in:
@@ -64,13 +64,12 @@ ENV PYTHONPATH=/build:/build/peikarband
|
|||||||
# Reflex needs to run from the directory containing rxconfig.py
|
# Reflex needs to run from the directory containing rxconfig.py
|
||||||
RUN cd /build/peikarband && \
|
RUN cd /build/peikarband && \
|
||||||
reflex init --loglevel debug || true && \
|
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 "Frontend export completed" && \
|
||||||
# Ensure executable permissions for node_modules/.bin files in builder stage
|
if [ -d .web/node_modules/.bin ]; then \
|
||||||
# This ensures they are preserved when copying to runtime stage
|
find .web/node_modules/.bin -type f -exec chmod +x {} \; && \
|
||||||
RUN if [ -d /build/peikarband/.web/node_modules/.bin ]; then \
|
find .web/node_modules/.bin -type l -exec chmod +x {} \; && \
|
||||||
find /build/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; && \
|
echo "✅ Set executable permissions for all .bin files (files and symlinks)"; \
|
||||||
echo "✅ Set executable permissions for .bin files in builder"; \
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Note: reflex export already builds and installs everything needed
|
# Note: reflex export already builds and installs everything needed
|
||||||
@@ -119,8 +118,7 @@ COPY --from=builder /usr/local/bin /usr/local/bin
|
|||||||
|
|
||||||
# Copy application code to /app/peikarband/ to create peikarband.peikarband structure
|
# Copy application code to /app/peikarband/ to create peikarband.peikarband structure
|
||||||
# With app_name="peikarband", Reflex expects to find peikarband.peikarband module
|
# With app_name="peikarband", Reflex expects to find peikarband.peikarband module
|
||||||
# Use --chmod to preserve executable permissions for node_modules/.bin
|
COPY --from=builder --chown=peikarband:peikarband /build/peikarband /app/peikarband
|
||||||
COPY --from=builder --chown=peikarband:peikarband --chmod=755 /build/peikarband /app/peikarband
|
|
||||||
|
|
||||||
# Copy entrypoint script
|
# Copy entrypoint script
|
||||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
@@ -130,10 +128,12 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
|
|||||||
RUN mkdir -p /app/data /app/logs /app/uploaded_files
|
RUN mkdir -p /app/data /app/logs /app/uploaded_files
|
||||||
|
|
||||||
# Set proper permissions for application files
|
# Set proper permissions for application files
|
||||||
# Explicitly set executable permissions for node_modules/.bin files
|
# Explicitly set executable permissions for node_modules/.bin files (both files and symlinks)
|
||||||
RUN if [ -d /app/peikarband/.web/node_modules/.bin ]; then \
|
RUN if [ -d /app/peikarband/.web/node_modules/.bin ]; then \
|
||||||
chmod +x /app/peikarband/.web/node_modules/.bin/* && \
|
find /app/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; && \
|
||||||
echo "✅ Set executable permissions for .bin files"; \
|
find /app/peikarband/.web/node_modules/.bin -type l -exec chmod +x {} \; && \
|
||||||
|
ls -la /app/peikarband/.web/node_modules/.bin/ | head -20 && \
|
||||||
|
echo "✅ Verified executable permissions for .bin files"; \
|
||||||
fi && \
|
fi && \
|
||||||
chmod -R 777 /app/data /app/logs /app/uploaded_files
|
chmod -R 777 /app/data /app/logs /app/uploaded_files
|
||||||
|
|
||||||
@@ -150,9 +150,20 @@ ENV PYTHONUNBUFFERED=1 \
|
|||||||
REFLEX_DIR=/app/peikarband \
|
REFLEX_DIR=/app/peikarband \
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# Health check
|
# Diagnostic information (before switching to non-root user)
|
||||||
|
RUN echo "=== Diagnostic Info ===" && \
|
||||||
|
if [ -f /app/peikarband/.web/node_modules/.bin/react-router ]; then \
|
||||||
|
ls -la /app/peikarband/.web/node_modules/.bin/react-router && \
|
||||||
|
file /app/peikarband/.web/node_modules/.bin/react-router || true; \
|
||||||
|
fi && \
|
||||||
|
if [ -f /app/peikarband/.web/node_modules/@react-router/dev/bin.js ]; then \
|
||||||
|
head -5 /app/peikarband/.web/node_modules/@react-router/dev/bin.js || true; \
|
||||||
|
fi && \
|
||||||
|
echo "======================="
|
||||||
|
|
||||||
|
# Health check (using backend health endpoint on port 8000)
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
CMD curl -f http://localhost:${PORT:-3000}/_health || exit 1
|
CMD curl -f http://localhost:8000/ping || exit 1
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER peikarband
|
USER peikarband
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Validate node_modules permissions before starting
|
||||||
|
if [ -d /app/peikarband/.web/node_modules/.bin ]; then
|
||||||
|
echo "Checking node_modules/.bin permissions..."
|
||||||
|
if [ ! -x /app/peikarband/.web/node_modules/.bin/react-router ]; then
|
||||||
|
echo "WARNING: react-router is not executable, attempting to fix..."
|
||||||
|
chmod +x /app/peikarband/.web/node_modules/.bin/* 2>/dev/null || true
|
||||||
|
echo "Permission fix attempted (may fail if running as non-root)"
|
||||||
|
else
|
||||||
|
echo "✅ react-router is executable"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Change to the directory containing rxconfig.py
|
# Change to the directory containing rxconfig.py
|
||||||
cd /app/peikarband
|
cd /app/peikarband
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ config = rx.Config(
|
|||||||
frontend_port=FRONTEND_PORT,
|
frontend_port=FRONTEND_PORT,
|
||||||
backend_port=BACKEND_PORT,
|
backend_port=BACKEND_PORT,
|
||||||
db_url=DB_URL,
|
db_url=DB_URL,
|
||||||
|
state_auto_setters=True, # Temporary fix for 0.8.9+ deprecation warning
|
||||||
disable_plugins=["reflex.plugins.sitemap.SitemapPlugin"],
|
disable_plugins=["reflex.plugins.sitemap.SitemapPlugin"],
|
||||||
stylesheets=[
|
stylesheets=[
|
||||||
"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap",
|
"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap",
|
||||||
|
|||||||
Reference in New Issue
Block a user