# Use the pre-built Flow2API image from GitHub Container Registry FROM ghcr.io/gdtiti/flow2api:latest # Switch to root to fix permissions and setup USER root # Fix file permissions for HuggingFace Spaces RUN cd /app && \ # Create and fix log file permissions touch logs.txt && \ chmod 666 logs.txt && \ # Ensure data directory exists with proper permissions mkdir -p data && \ chmod 755 data && \ # Try to set proper ownership chown -R app:app /app 2>/dev/null || \ # If app user doesn't exist, make critical files world writable (chmod 777 logs.txt data && echo "Made files world writable as fallback") && \ echo "File permissions fixed" # Add startup script for debugging RUN echo '#!/bin/bash\n\ echo "=== Startup Debug Info ==="\n\ echo "User: $(whoami)"\n\ echo "Current dir: $(pwd)"\n\ echo "Listing /app:"\n\ ls -la /app/\n\ echo "Checking logs.txt permissions:"\n\ ls -la /app/logs.txt\n\ echo "=== End Debug Info ==="\n\ exec python main.py' > /app/start_debug.sh && \ chmod +x /app/start_debug.sh # Set HuggingFace Spaces specific environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV FLOW2API_HOST=0.0.0.0 ENV FLOW2API_PORT=7860 # Add debug environment variables ENV FLOW2API_DEBUG_ENABLED=true ENV FLOW2API_DEBUG_LOG_REQUESTS=false ENV FLOW2API_DEBUG_LOG_RESPONSES=false # Switch back to app user if it exists USER app 2>/dev/null || USER root # Expose the HuggingFace Spaces default port EXPOSE 7860 # Health check for HuggingFace Spaces with longer startup time HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \ CMD python -c "import socket; s=socket.socket(); s.connect(('localhost', 7860)); s.close()" || exit 1 # Use debug startup script CMD ["/app/start_debug.sh"]