🚀 在现有 Dockerfile 的基础上,修改无浏览器镜像

This commit is contained in:
suyiiyii 2024-12-22 20:34:40 +08:00
parent 8c6e77dd94
commit 8550ff975a
Signed by: suyiiyii
GPG Key ID: 044704CB29B8AD85
3 changed files with 11 additions and 60 deletions

View File

@ -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 && \

View File

@ -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 && \

View File

@ -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")