Spaces:
Sleeping
Sleeping
| # MediLingua — single-container HF Space (Docker SDK) | |
| # Builds React frontend with Node 20, then runs FastAPI on port 7860. | |
| FROM python:3.11-slim | |
| # Install Node 20 via NodeSource + minimal build tools | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| ca-certificates \ | |
| gnupg \ | |
| && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | |
| && apt-get install -y --no-install-recommends nodejs ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # HF Spaces wants a non-root user. UID 1000 is the conventional choice. | |
| RUN useradd -m -u 1000 user | |
| # HF cache must live somewhere the non-root user can write. | |
| ENV HF_HOME=/tmp/huggingface \ | |
| TRANSFORMERS_CACHE=/tmp/huggingface \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PORT=7860 | |
| WORKDIR /app | |
| # --- Python deps (cached layer) --- | |
| COPY backend/requirements.txt /app/backend/requirements.txt | |
| RUN pip install --no-cache-dir -r /app/backend/requirements.txt | |
| # --- Frontend build (cached if package files unchanged) --- | |
| COPY frontend/package.json frontend/package-lock.json* /app/frontend/ | |
| WORKDIR /app/frontend | |
| # Use npm install if no lockfile, otherwise npm ci for reproducible builds. | |
| RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi | |
| # Copy frontend source and build | |
| COPY frontend/ /app/frontend/ | |
| RUN npm run build && rm -rf node_modules | |
| # --- Backend source --- | |
| WORKDIR /app | |
| COPY backend/ /app/backend/ | |
| # Make /tmp/huggingface writeable for cached HF artifacts | |
| RUN mkdir -p /tmp/huggingface && chown -R user:user /tmp/huggingface /app | |
| USER 1000 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"] | |