Spaces:
Sleeping
Sleeping
Download Dockerfile from harshisageek/stockproject: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/harshisageek/stockproject/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/harshisageek/stockproject/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/harshisageek/stockproject/resolve/main/Dockerfile
1.51 kB
| # Use Python 3.10 Slim image for a smaller footprint | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies (needed for some Python packages like lxml) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libxml2-dev \ | |
| libxslt-dev \ | |
| git-lfs \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements-hf.txt requirements.txt | |
| # Install Python dependencies | |
| # Use --no-cache-dir to keep image size down | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the application code | |
| # We copy the 'backend' and 'brain' folders to the root of the container | |
| COPY backend/ backend/ | |
| COPY brain/ brain/ | |
| COPY models/ models/ | |
| # Create a non-root user for security (Required by Hugging Face Spaces) | |
| RUN useradd -m -u 1000 user && chown -R user:user /app | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set PYTHONPATH so backend/app.py can import 'brain' | |
| ENV PYTHONPATH=/app | |
| # Expose the port that Hugging Face Spaces uses (7860) | |
| EXPOSE 7860 | |
| # Run the application using Gunicorn (Production Server) | |
| # We need to install gunicorn first if it's not in requirements.txt | |
| RUN pip install gunicorn | |
| # Command to run the app | |
| # -w 1: 1 worker (limited resources on free tier) | |
| # -b 0.0.0.0:7860: Bind to all interfaces on port 7860 | |
| # --timeout 120: Increase timeout for ML model loading | |
| CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "300", "backend.app:app"] | |