Spaces:
Running
Running
| # ============================================ | |
| # FetalCLIP - Hugging Face Spaces Docker Image | |
| # ============================================ | |
| # This Dockerfile creates a container that runs: | |
| # - FastAPI backend on port 7860 (HF Spaces requirement) | |
| # - Serves React frontend as static files | |
| # | |
| # Deploy to: https://huggingface.co/spaces | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Node.js for building frontend | |
| RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ | |
| && apt-get install -y nodejs \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy backend requirements first (for Docker caching) | |
| COPY backend/requirements.txt /app/backend/requirements.txt | |
| RUN pip install --no-cache-dir -r /app/backend/requirements.txt | |
| # Copy assets | |
| COPY assets /app/assets | |
| # Copy backend code | |
| COPY backend/app /app/backend/app | |
| # Copy frontend and build | |
| COPY frontend/package*.json /app/frontend/ | |
| WORKDIR /app/frontend | |
| RUN npm install | |
| COPY frontend /app/frontend | |
| RUN npm run build | |
| # Move built frontend to backend for serving | |
| RUN mkdir -p /app/backend/static && cp -r /app/frontend/dist/* /app/backend/static/ | |
| WORKDIR /app | |
| # Copy the HF Spaces specific server | |
| COPY server.py /app/server.py | |
| # Expose port 7860 (Hugging Face Spaces requirement) | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV HF_HOME=/app/.cache | |
| # Create cache directory | |
| RUN mkdir -p /app/.cache | |
| # Run the server | |
| CMD ["python", "server.py"] | |