From f5a5e03269f524eec255e78363996536efb4bbee Mon Sep 17 00:00:00 2001 From: Lan Date: Sat, 24 Jan 2026 10:31:43 +0800 Subject: [PATCH] feat: update Dockerfile for multi-stage build and add frontend themes; update dependencies in requirements.txt --- Dockerfile | 27 ++++++++++++++++++++++++++- core/response.py | 4 ++-- requirements.txt | 14 +++++++------- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index be2ece5..35c2fc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,25 @@ -FROM python:3.9.5-slim-buster +# 第一阶段:构建前端主题 +FROM node:18-alpine AS frontend-builder + +# 安装 git +RUN apk add --no-cache git + +WORKDIR /build + +# 克隆并构建 2024 主题 +RUN git clone --depth 1 https://github.com/vastsa/FileCodeBoxFronted.git fronted-2024 && \ + cd fronted-2024 && \ + npm install && \ + npm run build + +# 克隆并构建 2023 主题 +RUN git clone --depth 1 https://github.com/vastsa/FileCodeBoxFronted2023.git fronted-2023 && \ + cd fronted-2023 && \ + npm install && \ + npm run build + +# 第二阶段:构建最终镜像 +FROM python:3.12-slim-bookworm LABEL author="Lan" LABEL email="xzu@live.com" @@ -14,6 +35,10 @@ WORKDIR /app # 删除不必要的目录,减少镜像体积 RUN rm -rf docs fcb-fronted +# 从构建阶段复制编译好的前端主题 +COPY --from=frontend-builder /build/fronted-2024/dist /app/themes/2024 +COPY --from=frontend-builder /build/fronted-2023/dist /app/themes/2023 + # 安装依赖 RUN pip install -r requirements.txt diff --git a/core/response.py b/core/response.py index 5769111..e2b4325 100644 --- a/core/response.py +++ b/core/response.py @@ -4,12 +4,12 @@ # @Software: PyCharm from typing import Generic, TypeVar -from pydantic.v1.generics import GenericModel +from pydantic import BaseModel T = TypeVar("T") -class APIResponse(GenericModel, Generic[T]): +class APIResponse(BaseModel, Generic[T]): code: int = 200 message: str = "ok" detail: T diff --git a/requirements.txt b/requirements.txt index 3a87944..d5d62a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -aioboto3==13.4.0 +aioboto3==15.5.0 aiohttp==3.13.3 -aiofiles==24.1.0 -fastapi==0.115.6 -pydantic==2.10.4 -uvicorn==0.34.0 -tortoise-orm==0.22.1 -python-multipart==0.0.20 +aiofiles==25.1.0 +fastapi==0.128.0 +pydantic==2.12.5 +uvicorn==0.40.0 +tortoise-orm==0.25.3 +python-multipart==0.0.21