From 433b535546570583a540bacc3f0404eb082d9622 Mon Sep 17 00:00:00 2001 From: ITQ Date: Sat, 15 Feb 2025 15:18:17 +0300 Subject: [PATCH] infra: added Dockerfile for telegram_bot service --- solution/services/telegram_bot/Dockerfile | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 solution/services/telegram_bot/Dockerfile diff --git a/solution/services/telegram_bot/Dockerfile b/solution/services/telegram_bot/Dockerfile new file mode 100644 index 0000000..4f90ebf --- /dev/null +++ b/solution/services/telegram_bot/Dockerfile @@ -0,0 +1,37 @@ +# Stage 1: Install dependencies +FROM docker.io/python:3.11-alpine3.20 AS builder + +COPY --from=ghcr.io/astral-sh/uv:0.4.30 /uv /uvx /bin/ + +WORKDIR /app + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONOPTIMIZE=2 \ + UV_COMPILE_BYTECODE=1 \ + UV_PROJECT_ENVIRONMENT=/opt/venv + +COPY pyproject.toml . + +RUN uv sync --no-dev --no-install-project --no-cache + + +# Stage 2: Start the application +FROM docker.io/python:3.11-alpine3.20 + +WORKDIR /app + +COPY --from=builder /opt/venv /opt/venv + +COPY . . + +RUN adduser -D -g '' app && chown -R app:app ./ + +USER app + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONOPTIMIZE=2 \ + PATH="/opt/venv/bin:$PATH" + +CMD python main.py