43 lines
1.3 KiB
Docker
43 lines
1.3 KiB
Docker
# --- build stage: собираем wheels для runtime-образа ---
|
|
FROM python:3.12-slim AS builder
|
|
WORKDIR /build
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential gcc libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY requirements.txt .
|
|
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
|
|
|
|
# --- runtime stage ---
|
|
FROM python:3.12-slim AS runtime
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq5 curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& groupadd --system --gid 1000 panel \
|
|
&& useradd --system --uid 1000 --gid panel --home-dir /app panel
|
|
|
|
COPY --from=builder /wheels /wheels
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --no-index --find-links=/wheels -r requirements.txt \
|
|
&& rm -rf /wheels
|
|
|
|
RUN chown -R panel:panel /app
|
|
COPY --chown=panel:panel app ./app
|
|
|
|
# Применяем исправление LXC для Proxmox VE 9 до перехода на non-root.
|
|
COPY patch_lxc.py /tmp/patch_lxc.py
|
|
RUN python /tmp/patch_lxc.py && rm /tmp/patch_lxc.py \
|
|
&& chown panel:panel /app/app/proxmox_client.py
|
|
|
|
USER panel
|
|
|
|
EXPOSE 8000
|
|
|
|
HEALTHCHECK --interval=15s --timeout=5s --retries=3 --start-period=20s \
|
|
CMD curl -fsS http://localhost:8000/health || exit 1
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|