From 82f86ef8eec71aa212fcd320773e36963e4e5c8e Mon Sep 17 00:00:00 2001 From: austnv Date: Sun, 14 Jun 2026 22:11:03 +0300 Subject: [PATCH] update docker working process on server utilize ~200 Mb RAM --- Dockerfile | 14 ++++++++++++++ docker-compose.yml | 17 +++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42c1859 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM ghcr.io/astral-sh/uv:python3.12-alpine AS builder +ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy +WORKDIR /app +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + uv sync --frozen --no-dev --no-install-project + +FROM python:3.12-alpine +WORKDIR /app +COPY --from=builder /app/.venv /app/.venv +COPY . /app +ENV PATH="/app/.venv/bin:$PATH" +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/docker-compose.yml b/docker-compose.yml index 3815c9e..1a0ad50 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,11 @@ services: backend: - image: python:3.12-alpine + build: . container_name: uvpn-backend - working_dir: /app - volumes: - - .:/app - - /app/.venv - environment: - - UV_COMPILE_BYTECODE=1 - - UV_LINK_MODE=copy expose: - 8000 - command: > - sh -c "pip install --no-cache-dir uv && - uv sync --frozen --no-dev && - uv run uvicorn main:app --host 0.0.0.0 --port 8000 --reload" networks: - - remnawave-network + - remnawave-network restart: unless-stopped healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/api/v1/health', timeout=3).read()"] @@ -27,4 +16,4 @@ services: networks: remnawave-network: - external: true \ No newline at end of file + external: true