feat: docker & startup

This commit is contained in:
2026-06-06 12:30:49 +03:00
parent 93199a3095
commit 63546c1fe3
4 changed files with 44 additions and 5 deletions
+34
View File
@@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1
# DEV image: source is bind-mounted by compose, uvicorn runs with --reload.
# Build context = mcma-backend/ (see docker-compose.yml).
FROM python:3.14-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_LINK_MODE=copy \
VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Runtime tools: ffmpeg (transcode/HLS), fpcalc (Chromaprint fingerprinting).
RUN apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg libchromaprint-tools \
&& rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.4 /uv /uvx /bin/
WORKDIR /app
# Dependency layer (incl. dev group for tooling) — cached unless lockfile changes.
COPY pyproject.toml uv.lock* ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project
# Project layer. At runtime compose bind-mounts the live source over this.
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen
EXPOSE 8000
# --reload watches /app (the bind mount) and restarts on edit.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
+36
View File
@@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1
# PROD image: self-contained, no dev deps, no source mount.
# Single image serves both `api` and `worker` (different commands at runtime).
# Build context = mcma-backend/.
FROM python:3.14-slim AS base
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Runtime tools: ffmpeg (transcode/HLS), fpcalc (Chromaprint fingerprinting).
RUN apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg libchromaprint-tools \
&& rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.4 /uv /uvx /bin/
WORKDIR /app
# Dependency layer (prod only) — cached unless lockfile changes.
COPY pyproject.toml uv.lock* ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# Project layer.
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
EXPOSE 8000
# Default: API server. Worker overrides command (arq ...) at runtime.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]