feat: update Dockerfile for multi-stage build and add frontend themes; update dependencies in requirements.txt

This commit is contained in:
Lan
2026-01-24 10:31:43 +08:00
parent f94f819fc1
commit 956effc384
3 changed files with 35 additions and 10 deletions
+26 -1
View File
@@ -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