-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (27 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
36 lines (27 loc) · 1.27 KB
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
# Stage 1: Builder — exports dependencies without dev packages
FROM python:3.11-slim AS builder
WORKDIR /app
# Використовуємо версію Poetry, сумісну з твоїм середовищем
ENV POETRY_VERSION=1.8.2
RUN pip install --no-cache-dir "poetry==$POETRY_VERSION" poetry-plugin-export
COPY pyproject.toml poetry.lock* ./
RUN poetry export -f requirements.txt --output requirements.txt --without dev
# Stage 2: Final — lean runtime image
FROM python:3.11-slim
WORKDIR /app
# Забороняємо Python писати .pyc файли та буферизувати stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
# Встановлюємо curl для healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# Створюємо non-root користувача для безпеки
RUN groupadd -r ai_email && useradd -r -g ai_email ai_email
# Встановлюємо залежності
COPY --from=builder /app/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Копіюємо вихідний код
COPY . .
# Передаємо права non-root користувачу
RUN chown -R ai_email:ai_email /app
USER ai_email