Files
backend-python/template/backend/Dockerfile.jinja
T
2026-09-08 19:17:12 +02:00

41 lines
1.3 KiB
Docker

{%- set svc_modules = [] -%}
{%- if 'api' in backend_services %}{% set _ = svc_modules.append("api") %}{% endif -%}
{%- if 'aiogram_bot' in backend_services %}{% set _ = svc_modules.append("bot") %}{% endif -%}
{%- if 'taskiq_worker' in backend_services %}{% set _ = svc_modules.append("worker") %}{% endif -%}
{%- if 'kurigram_userbot' in backend_services %}{% set _ = svc_modules.append("userbot") %}{% endif -%}
{%- if 'scheduler' in backend_services and 'taskiq_worker' not in backend_services %}{% set _ = svc_modules.append("scheduler") %}{% endif -%}
{%- if 'kurigram_userbot' in backend_services -%}
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/*
{%- else -%}
FROM ghcr.io/astral-sh/uv:python3.13-alpine
{%- endif %}
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH" \
RUN_ENVIRONMENT=prod \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project --no-dev
COPY src ./src
RUN uv sync --frozen --no-dev
{%- if database == 'postgres' %}
COPY alembic.ini ./
COPY migrations ./migrations
{%- endif %}
{%- if dynamic_config or 'kurigram_userbot' in backend_services %}
COPY scripts ./scripts
{%- endif %}
ENTRYPOINT ["python", "-m"]
{%- if svc_modules %}
CMD ["{{ svc_modules[0] }}"]
{%- endif %}