|
|
|
FROM python:3.11-slim |
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \ |
|
PYTHONUNBUFFERED=1 \ |
|
PYTHONPATH=/app \ |
|
PORT=8000 |
|
|
|
|
|
RUN groupadd --gid 1000 appuser && \ |
|
useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
--no-install-recommends \ |
|
build-essential \ |
|
curl \ |
|
&& rm -rf /var/lib/apt/lists/* \ |
|
&& apt-get clean |
|
|
|
|
|
COPY requirements.txt . |
|
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip && \ |
|
pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
COPY main.py . |
|
|
|
|
|
RUN chown -R appuser:appuser /app |
|
|
|
|
|
USER appuser |
|
|
|
|
|
EXPOSE 8000 |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ |
|
CMD curl -f http://localhost:8000/health || exit 1 |
|
|
|
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"] |