diff --git a/.dockerignore b/.dockerignore index fd9b0abc..56143f4c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,10 @@ __pycache__/ .pytest_cache/ .coverage htmlcov/ +.venv/ +tests/ +.mypy_cache/ +.ruff_cache/ # Environment files .env diff --git a/Dockerfile b/Dockerfile index 47510a48..80b718dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,13 +4,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ && rm -rf /var/lib/apt/lists/* -RUN python -m venv /opt/venv -ENV PATH="/opt/venv/bin:$PATH" +COPY --from=ghcr.io/astral-sh/uv:0.10.7 /uv /uvx /bin/ -COPY requirements.txt . +ENV UV_COMPILE_BYTECODE=1 \ + UV_LINK_MODE=copy \ + UV_PYTHON_DOWNLOADS=never -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt +WORKDIR /app + +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + uv sync --locked --no-dev FROM python:3.13-slim @@ -18,13 +23,8 @@ ARG VERSION="v3.18.0" # x-release-please-version ARG BUILD_DATE ARG VCS_REF -RUN apt-get update && apt-get install -y --no-install-recommends \ - wget \ - && rm -rf /var/lib/apt/lists/* \ - && apt-get clean - -COPY --from=builder /opt/venv /opt/venv -ENV PATH="/opt/venv/bin:$PATH" +COPY --from=builder /app/.venv /app/.venv +ENV PATH="/app/.venv/bin:$PATH" RUN groupadd -g 1000 app && \ useradd -u 1000 -g 1000 -m -s /bin/bash app @@ -33,8 +33,7 @@ WORKDIR /app COPY --chown=app:app . . -RUN mkdir -p logs data && \ - chown -R app:app /app logs data +RUN mkdir -p logs data && chown app:app logs data USER app @@ -56,7 +55,7 @@ LABEL org.opencontainers.image.title="Bedolaga RemnaWave Bot" \ org.opencontainers.image.url="https://github.com/fr1ngg/remnawave-bedolaga-telegram-bot" \ org.opencontainers.image.vendor="fr1ngg" -HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1 +HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ + CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health')" || exit 1 CMD ["python", "main.py"]