Download Dockerfile from rastof9/fb: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/spaces/rastof9/fb/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/rastof9/fb/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/rastof9/fb/resolve/main/Dockerfile
2.09 kB
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV FLASK_APP=app.py | |
| ENV FLASK_ENV=development | |
| ENV PATH="/home/appuser/.local/bin:$PATH" | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV FLASK_DEBUG=1 | |
| # Install system dependencies for OpenCV and other requirements | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| tesseract-ocr \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user | |
| RUN useradd -m appuser && mkdir -p /app /app/instance /app/models && chown -R appuser:appuser /app | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy requirements and install dependencies | |
| COPY --chown=appuser:appuser requirements.txt . | |
| # Install dependencies with proper error handling | |
| RUN pip install --no-cache-dir "numpy<2.0.0" && \ | |
| pip install --no-cache-dir -r requirements.txt && \ | |
| # Verify critical packages are installed | |
| python -c "import flask, flask_sqlalchemy, redis, celery; print('All critical dependencies installed successfully')" | |
| # Download YOLO files | |
| RUN wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights -O /app/models/yolov4.weights && \ | |
| wget https://raw.githubusercontent.com/AlexeyAB/darknet/master/cfg/yolov4.cfg -O /app/models/yolov4.cfg && \ | |
| chown appuser:appuser /app/models/yolov4.* | |
| # Create a health check script | |
| RUN echo '#!/bin/sh\npython -c "import flask, flask_sqlalchemy, redis, celery; print(\"Dependencies OK\")"' > /app/healthcheck.sh | |
| # Copy the application code | |
| COPY --chown=appuser:appuser . . | |
| # Create a debug script | |
| RUN echo '#!/bin/bash\n\ | |
| echo "Starting app in debug mode..."\n\ | |
| python -m flask run --host=0.0.0.0 --port=5000 --debug\n\ | |
| ' > /app/debug.sh && chmod +x /app/debug.sh | |
| # Make scripts executable | |
| RUN chmod +x /app/prestart.sh /app/healthcheck.sh /app/start.sh /app/debug.sh | |
| # Switch to non-root user | |
| USER appuser | |
| # Expose the port | |
| EXPOSE 5000 | |
| # Run the application in debug mode | |
| CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=5000", "--debug"] |