mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
🚀 使用 带前端,sentry,浏览器的版本作为默认Dockerfile
This commit is contained in:
parent
93b6055391
commit
8c6e77dd94
@ -45,6 +45,55 @@ LABEL org.opencontainers.image.created="$(cat /tmp/CREATED_DATE)" \
|
|||||||
org.opencontainers.image.name="$(cat /tmp/PYPROJECT_NAME)" \
|
org.opencontainers.image.name="$(cat /tmp/PYPROJECT_NAME)" \
|
||||||
org.opencontainers.image.version="$(cat /tmp/VERSION)"
|
org.opencontainers.image.version="$(cat /tmp/VERSION)"
|
||||||
|
|
||||||
|
FROM node:20-slim AS frontend-stage
|
||||||
|
|
||||||
|
WORKDIR /tmp/admin-frontend
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai \
|
||||||
|
PNPM_HOME="/pnpm" \
|
||||||
|
PATH="$PNPM_HOME:$PATH"
|
||||||
|
|
||||||
|
COPY ./admin-frontend/package.json ./admin-frontend/pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
RUN corepack enable && \
|
||||||
|
corepack prepare pnpm@9.15.1 --activate && \
|
||||||
|
echo "🔔 Verifying Node.js installation..." && \
|
||||||
|
if NODE_VERSION=$(node --version 2>&1); then \
|
||||||
|
echo "✅ Node.js version ${NODE_VERSION} installed successfully"; \
|
||||||
|
else \
|
||||||
|
echo "❌ Node.js installation failed" && exit 1; \
|
||||||
|
fi && \
|
||||||
|
echo "🔔 Verifying pnpm installation..." && \
|
||||||
|
if PNPM_VERSION=$(pnpm --version 2>&1); then \
|
||||||
|
echo "✅ pnpm version ${PNPM_VERSION} installed successfully"; \
|
||||||
|
else \
|
||||||
|
echo "❌ pnpm installation failed" && exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY ./admin-frontend .
|
||||||
|
RUN mkdir -p ../nonebot_bison/admin_page/dist
|
||||||
|
|
||||||
|
RUN echo "🏗️ Starting frontend build..." && \
|
||||||
|
pnpm run build && \
|
||||||
|
echo "✅ Frontend build completed"
|
||||||
|
|
||||||
|
FROM python:3.12-slim AS playwright-stage
|
||||||
|
|
||||||
|
WORKDIR /tmp
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
|
PYTHONUNBUFFERED=1 \
|
||||||
|
TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
|
|
||||||
|
|
||||||
|
RUN echo "📦 Installing playwright..." && \
|
||||||
|
uvx playwright install --with-deps chromium && \
|
||||||
|
echo "✅ Playwright installed successfully"
|
||||||
|
|
||||||
FROM python:3.12-slim AS production
|
FROM python:3.12-slim AS production
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -55,32 +104,63 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|||||||
UV_SYSTEM_PYTHON=true \
|
UV_SYSTEM_PYTHON=true \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
UV_LINK_MODE=copy \
|
UV_LINK_MODE=copy \
|
||||||
TZ=Asia/Shanghai
|
TZ=Asia/Shanghai \
|
||||||
|
SHELL="/bin/bash" \
|
||||||
|
PNPM_HOME="/pnpm" \
|
||||||
|
PATH="/pnpm:${PATH}"
|
||||||
|
|
||||||
RUN echo "📦 Installing system dependencies..." && \
|
RUN echo "📦 Installing system dependencies..." && \
|
||||||
# --mount=type=cache,target=/var/cache/apt \
|
apt-get update && \
|
||||||
# --mount=type=cache,target=/var/lib/apt \
|
apt-get install -y --no-install-recommends \
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
curl \
|
||||||
curl \
|
xvfb \
|
||||||
xvfb \
|
fonts-noto-color-emoji \
|
||||||
fonts-noto-color-emoji fonts-unifont \
|
fonts-unifont \
|
||||||
libfontconfig1 libfreetype6 xfonts-scalable \
|
libfontconfig1 \
|
||||||
fonts-liberation fonts-ipafont-gothic \
|
libfreetype6 \
|
||||||
fonts-wqy-zenhei fonts-tlwg-loma-otf \
|
xfonts-scalable \
|
||||||
vim && \
|
fonts-liberation \
|
||||||
echo "🔍 Verifying Python installation..." && \
|
fonts-ipafont-gothic \
|
||||||
if PYTHON_VERSION=$(python3 --version 2>&1); then \
|
fonts-wqy-zenhei \
|
||||||
echo "✅ ${PYTHON_VERSION} installed successfully"; \
|
fonts-tlwg-loma-otf \
|
||||||
else \
|
at-spi2-common \
|
||||||
echo "❌ Python installation failed" && exit 1; \
|
fonts-freefont-ttf \
|
||||||
fi && \
|
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 && \
|
fc-cache -fv && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
echo "✅ System dependencies installed successfully"
|
echo "✅ System dependencies installed successfully"
|
||||||
|
|
||||||
|
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
RUN echo "🔍 Verifying uv installation..." && \
|
RUN echo "🔔 Verifying uv installation..." && \
|
||||||
if UV_VERSION=$(uv --version 2>&1); then \
|
if UV_VERSION=$(uv --version 2>&1); then \
|
||||||
echo "✅ uv version ${UV_VERSION} installed successfully"; \
|
echo "✅ uv version ${UV_VERSION} installed successfully"; \
|
||||||
else \
|
else \
|
||||||
@ -89,30 +169,26 @@ RUN echo "🔍 Verifying uv installation..." && \
|
|||||||
|
|
||||||
COPY ./pyproject.toml ./uv.lock ./
|
COPY ./pyproject.toml ./uv.lock ./
|
||||||
|
|
||||||
RUN echo "📦 Installing bison dependencies..." && \
|
RUN --mount=type=cache,target=/root/.cache/ \
|
||||||
|
--mount=type=cache,target=/root/.uv \
|
||||||
|
echo "📦 Installing bison dependencies..." && \
|
||||||
uv pip install --extra=docker --requirement pyproject.toml --no-cache && \
|
uv pip install --extra=docker --requirement pyproject.toml --no-cache && \
|
||||||
echo "✅ Dependencies installed successfully" && \
|
echo "✅ Dependencies installed successfully" && \
|
||||||
echo "🧹 Cleaning up uv..." && \
|
echo "🔔 Cleaning up uv..." && \
|
||||||
rm -rf /bin/uv /bin/uvx && \
|
rm -rf /bin/uv /bin/uvx && \
|
||||||
rm -rf /root/.cache/ && \
|
|
||||||
rm -rf /root/.uv && \
|
|
||||||
echo "✅ UV cleanup completed"
|
echo "✅ UV cleanup completed"
|
||||||
|
|
||||||
COPY --from=metadata-stage /tmp/VERSION /app/VERSION
|
COPY --from=metadata-stage /tmp/VERSION /app/VERSION
|
||||||
COPY . .
|
COPY nonebot_bison/ /app/nonebot_bison/
|
||||||
|
COPY --from=frontend-stage /tmp/nonebot_bison/admin_page/dist ./nonebot_bison/admin_page/dist
|
||||||
RUN echo "🎭 Installing Playwright..." && \
|
COPY --from=playwright-stage /root/.cache/ms-playwright /root/.cache/ms-playwright
|
||||||
playwright install --with-deps chromium && \
|
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* && \
|
|
||||||
mv docker.env.prod .env.prod && \
|
|
||||||
echo "✅ Playwright installed successfully"
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN echo '#!/bin/bash\n\
|
RUN echo '#!/bin/bash' > /app/start.sh && \
|
||||||
echo "📌 Current bison Version: $(cat /app/VERSION)"\n\
|
echo 'echo "📌 Current bison Version: $(cat /app/VERSION)"' >> /app/start.sh && \
|
||||||
echo "🚀 Starting backend service..."\n\
|
echo 'echo "🚀 Starting service..."' >> /app/start.sh && \
|
||||||
nb run' > /app/start.sh && \
|
echo 'nb run' >> /app/start.sh && \
|
||||||
chmod +x /app/start.sh
|
chmod +x /app/start.sh
|
||||||
|
|
||||||
CMD ["/app/start.sh"]
|
CMD ["/app/start.sh"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user