chore: add docker

This commit is contained in:
2026-05-11 12:43:49 +03:00
parent 7dbbd98312
commit f00551b2d1
2 changed files with 45 additions and 0 deletions

28
Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS builder
WORKDIR /app
# Install dependencies (cached layer)
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev
# Copy source last (fast rebuilds)
COPY src ./src
FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS runtime
WORKDIR /app
# Use the virtualenv created by `uv sync` in builder
COPY --from=builder /app/.venv /app/.venv
COPY --from=builder /app/src /app/src
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app
EXPOSE 8000
CMD ["sh", "-c", "granian --interface asgi ${APP_MODULE:-src.main:app} --host ${APP_HOST:-0.0.0.0} --port ${APP_PORT:-8000} --workers ${APP_WORKERS:-1} --loop uvloop"]

17
docker-compose.yml Normal file
View File

@@ -0,0 +1,17 @@
services:
kyc:
container_name: kyc
build:
context: .
dockerfile: Dockerfile
ports:
- "7000:7000"
environment:
PYTHONUNBUFFERED: "1"
APP_MODULE: "src.main:app"
APP_HOST: "0.0.0.0"
APP_PORT: "8000"
APP_WORKERS: "1"
env_file:
- .env
restart: no