| |
| |
|
|
| |
| FROM python:3.11-slim as builder |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| build-essential \ |
| libsm6 \ |
| libxext6 \ |
| libxrender-dev \ |
| libgl1 \ |
| libglib2.0-0 \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN python -m venv /opt/venv |
| ENV PATH="/opt/venv/bin:$PATH" |
|
|
| |
| COPY requirements.txt . |
|
|
| |
| RUN pip install --no-cache-dir --upgrade pip && \ |
| pip install --no-cache-dir -r requirements.txt |
|
|
| |
| FROM python:3.11-slim |
|
|
| |
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| libsm6 \ |
| libxext6 \ |
| libxrender-dev \ |
| libgl1 \ |
| libglib2.0-0 \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN useradd -m -u 1000 appuser |
|
|
| |
| WORKDIR /app |
|
|
| |
| COPY --from=builder --chown=appuser:appuser /opt/venv /opt/venv |
|
|
| |
| COPY --chown=appuser:appuser . /app |
|
|
| |
| RUN chown -R appuser:appuser /app |
|
|
| |
| ENV PATH="/opt/venv/bin:$PATH" \ |
| PYTHONUNBUFFERED=1 \ |
| PYTHONDONTWRITEBYTECODE=1 |
|
|
| |
| USER appuser |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ |
| CMD curl -f http://localhost:7860/health || exit 1 |
|
|
| |
| CMD ["python", "-m", "uvicorn", "backend:app", "--host", "0.0.0.0", "--port", "7860"] |
|
|