From 8550ff975ad8a32b9c7f92f5c34cb931e7530be4 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Sun, 22 Dec 2024 20:34:40 +0800 Subject: [PATCH] =?UTF-8?q?:rocket:=20=E5=9C=A8=E7=8E=B0=E6=9C=89=20Docker?= =?UTF-8?q?file=20=E7=9A=84=E5=9F=BA=E7=A1=80=E4=B8=8A=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=A0=E6=B5=8F=E8=A7=88=E5=99=A8=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/Dockerfile | 4 +- ...th_frontend => Dockerfile_without_browser} | 61 ++----------------- nonebot_bison/platform/bilibili/scheduler.py | 6 +- 3 files changed, 11 insertions(+), 60 deletions(-) rename docker/{Dockerfile_with_frontend => Dockerfile_without_browser} (76%) diff --git a/docker/Dockerfile b/docker/Dockerfile index 40987e8..357a858 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -105,9 +105,7 @@ ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ UV_LINK_MODE=copy \ TZ=Asia/Shanghai \ - SHELL="/bin/bash" \ - PNPM_HOME="/pnpm" \ - PATH="/pnpm:${PATH}" + SHELL="/bin/bash" RUN echo "📦 Installing system dependencies..." && \ apt-get update && \ diff --git a/docker/Dockerfile_with_frontend b/docker/Dockerfile_without_browser similarity index 76% rename from docker/Dockerfile_with_frontend rename to docker/Dockerfile_without_browser index 40987e8..65eeed6 100644 --- a/docker/Dockerfile_with_frontend +++ b/docker/Dockerfile_without_browser @@ -98,66 +98,14 @@ FROM python:3.12-slim AS production WORKDIR /app -#ENV UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ + ENV DEBIAN_FRONTEND=noninteractive \ UV_COMPILE_BYTECODE=1 \ UV_SYSTEM_PYTHON=true \ PYTHONUNBUFFERED=1 \ UV_LINK_MODE=copy \ TZ=Asia/Shanghai \ - SHELL="/bin/bash" \ - PNPM_HOME="/pnpm" \ - PATH="/pnpm:${PATH}" - -RUN echo "📦 Installing system dependencies..." && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - curl \ - xvfb \ - fonts-noto-color-emoji \ - fonts-unifont \ - libfontconfig1 \ - libfreetype6 \ - xfonts-scalable \ - fonts-liberation \ - fonts-ipafont-gothic \ - fonts-wqy-zenhei \ - fonts-tlwg-loma-otf \ - at-spi2-common \ - fonts-freefont-ttf \ - libasound2 \ - libasound2-data \ - libatk-bridge2.0-0 \ - libatk1.0-0 \ - libatspi2.0-0 \ - libavahi-client3 \ - libavahi-common-data \ - libavahi-common3 \ - libcairo2 \ - libcups2 \ - libdatrie1 \ - libdbus-1-3 \ - libfribidi0 \ - libgbm1 \ - libglib2.0-0 \ - libgraphite2-3 \ - libharfbuzz0b \ - libnspr4 \ - libnss3 \ - libpango-1.0-0 \ - libthai-data \ - libthai0 \ - libwayland-server0 \ - libxcb-render0 \ - libxcomposite1 \ - libxdamage1 \ - libxi6 \ - libxkbcommon0 && \ - fc-cache -fv && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* && \ - echo "✅ System dependencies installed successfully" - + SHELL="/bin/bash" COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ RUN echo "🔔 Verifying uv installation..." && \ @@ -168,6 +116,7 @@ RUN echo "🔔 Verifying uv installation..." && \ fi COPY ./pyproject.toml ./uv.lock ./ +COPY ./docker.env.prod ./.env RUN --mount=type=cache,target=/root/.cache/ \ --mount=type=cache,target=/root/.uv \ @@ -181,10 +130,12 @@ RUN --mount=type=cache,target=/root/.cache/ \ COPY --from=metadata-stage /tmp/VERSION /app/VERSION COPY nonebot_bison/ /app/nonebot_bison/ COPY --from=frontend-stage /tmp/nonebot_bison/admin_page/dist ./nonebot_bison/admin_page/dist -COPY --from=playwright-stage /root/.cache/ms-playwright /root/.cache/ms-playwright EXPOSE 8080 +ENV BISON_SKIP_BROWSER_CHECK=True \ + BISON_USE_BROWSER=False + RUN echo '#!/bin/bash' > /app/start.sh && \ echo 'echo "📌 Current bison Version: $(cat /app/VERSION)"' >> /app/start.sh && \ echo 'echo "🚀 Starting service..."' >> /app/start.sh && \ diff --git a/nonebot_bison/platform/bilibili/scheduler.py b/nonebot_bison/platform/bilibili/scheduler.py index b63fa3b..0329243 100644 --- a/nonebot_bison/platform/bilibili/scheduler.py +++ b/nonebot_bison/platform/bilibili/scheduler.py @@ -9,14 +9,16 @@ from nonebot import logger, require from playwright.async_api import Cookie from nonebot_bison.config.db_model import Cookie as CookieModel +from nonebot_bison.plugin_config import plugin_config from nonebot_bison.utils import Site, http_client from nonebot_bison.utils.site import CookieClientManager if TYPE_CHECKING: from .platforms import Bilibili -require("nonebot_plugin_htmlrender") -from nonebot_plugin_htmlrender import get_browser +if plugin_config.bison_use_browser: + require("nonebot_plugin_htmlrender") + from nonebot_plugin_htmlrender import get_browser B = TypeVar("B", bound="Bilibili")