File size: 1,262 Bytes
8f20af8 | 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 | # Build Stage 1: Build React frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /build
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Build Stage 2: Python Serving Backend
FROM python:3.11-slim
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user (UID 1000 for Hugging Face Spaces compatibility)
RUN useradd -m -u 1000 appuser
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir huggingface_hub
# Copy application code
COPY src/ src/
COPY configs/ configs/
COPY config/ config/
COPY db/ db/
COPY NOTICE .
COPY README.md .
# Copy compiled frontend into directory served by FastAPI
COPY --from=frontend-builder /build/dist frontend/dist
# Set permissions for non-root execution
RUN chown -R appuser:appuser /app
USER appuser
EXPOSE 7860 8000
ENV APP_PROFILE=demo
ENV PORT=7860
ENV HOST=0.0.0.0
ENV MODEL_BACKEND=mock
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
CMD ["sh", "-c", "uvicorn src.t2s.serving.app:app --host 0.0.0.0 --port ${PORT:-7860}"]
|