Spaces:
Running
Running
# Build stage | |
FROM python:3.11-slim as builder | |
WORKDIR /app | |
COPY requirements.txt . | |
# Install dependencies in a virtual environment | |
RUN python -m venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Runtime stage | |
FROM python:3.11-slim | |
# Install minimal runtime dependencies | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
libgomp1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
WORKDIR /app | |
# Copy virtual environment from builder | |
COPY --from=builder /opt/venv /opt/venv | |
ENV PATH="/opt/venv/bin:$PATH" | |
# Copy application code | |
COPY . . | |
# Set environment variables | |
ENV PYTHONUNBUFFERED=1 | |
ENV GRADIO_SERVER_NAME=0.0.0.0 | |
ENV GRADIO_SERVER_PORT=80 | |
# Health check | |
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | |
CMD curl -f http://localhost:80 || exit 1 | |
# Expose port | |
EXPOSE 80 | |
# Run the application | |
CMD ["python", "webui.py"] | |