Spaces:
Running
Running
File size: 1,634 Bytes
a874986 c99b600 a874986 2dc7879 a874986 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# ============================================
# 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"]
|