From 0a31601b7718f4a35ea308d40d7522ba05c6d18d Mon Sep 17 00:00:00 2001 From: mr-forust Date: Thu, 21 May 2026 22:12:33 +0200 Subject: [PATCH] refactor: imporved layer caching for dockerfile using existing built image for account 2 --- userbot/.dockerignore | 10 ++++++++++ userbot/Dockerfile | 24 ++++++++++++++++-------- userbot/compose.yaml | 5 ++--- userbot/pyproject.toml | 2 +- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/userbot/.dockerignore b/userbot/.dockerignore index ed7cba4..f836c8d 100644 --- a/userbot/.dockerignore +++ b/userbot/.dockerignore @@ -1 +1,11 @@ .unused +Downloads +.venv +volumes +.env +.env.* +my_account.session +.gitignore +README.md +.git +uv.lock \ No newline at end of file diff --git a/userbot/Dockerfile b/userbot/Dockerfile index 8f85225..0091949 100644 --- a/userbot/Dockerfile +++ b/userbot/Dockerfile @@ -1,10 +1,18 @@ -FROM python:3.11 +FROM python:3.11-slim + WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git wget ffmpeg mediainfo && \ + rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /app/ + +RUN python -m pip install --no-cache-dir --upgrade pip && \ + python -m pip install --no-cache-dir -r /app/requirements.txt + COPY . /app -RUN apt-get -qq update && apt-get -qq install -y git wget ffmpeg mediainfo\ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -RUN python -m venv --copies /opt/venv -ENV PATH="/opt/venv/bin:$PATH" -RUN pip install --no-cache-dir -r requirements.txt -CMD ["python", "main.py"] + +ENV PYTHONUNBUFFERED=1 + +CMD ["python", "-u", "main.py"] \ No newline at end of file diff --git a/userbot/compose.yaml b/userbot/compose.yaml index 9cf008f..8714b67 100644 --- a/userbot/compose.yaml +++ b/userbot/compose.yaml @@ -3,6 +3,7 @@ services: build: context: . dockerfile: Dockerfile + image: userbot:latest restart: unless-stopped env_file: - .env @@ -16,9 +17,7 @@ services: - 1.1.1.1 anna: - build: - context: . - dockerfile: Dockerfile + image: userbot:latest restart: unless-stopped env_file: - .env diff --git a/userbot/pyproject.toml b/userbot/pyproject.toml index d97068a..7850b35 100644 --- a/userbot/pyproject.toml +++ b/userbot/pyproject.toml @@ -3,7 +3,7 @@ name = "userbot" version = "0.1.0" description = "Add your description here" readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.11" dependencies = [ "aiofiles>=25.1.0", "aiohttp>=3.13.2",