mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-01 11:39:33 +08:00
Merge pull request #302 from JefferyHcool/feature/optimize-build
feat(build): 全面优化打包流程,Docker 镜像自动发布到 GHCR
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
RUN rm -f /etc/apt/sources.list && \
|
||||
rm -rf /etc/apt/sources.list.d/* && \
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
echo "deb https://${APT_MIRROR}/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
|
||||
echo "deb https://${APT_MIRROR}/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
echo "deb https://${APT_MIRROR}/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||
apt-get update && \
|
||||
apt-get install -y ffmpeg && \
|
||||
apt-get install -y --no-install-recommends ffmpeg curl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 确保 PATH 中包含 ffmpeg 路径(可选)
|
||||
ENV PATH="/usr/bin:${PATH}"
|
||||
|
||||
# 设置 Hugging Face 镜像源环境变量
|
||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 先复制 requirements.txt 利用层缓存
|
||||
COPY ./backend/requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir -i ${PIP_INDEX} -r requirements.txt
|
||||
|
||||
# 再复制应用代码(频繁变动不影响 pip 缓存层)
|
||||
COPY ./backend /app
|
||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
||||
|
||||
CMD ["python", "main.py"]
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y ffmpeg python3-pip && \
|
||||
apt clean all && \
|
||||
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
RUN rm -f /etc/apt/sources.list && \
|
||||
rm -rf /etc/apt/sources.list.d/* && \
|
||||
echo "deb https://${APT_MIRROR}/ubuntu jammy main restricted universe multiverse" > /etc/apt/sources.list && \
|
||||
echo "deb https://${APT_MIRROR}/ubuntu jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
|
||||
echo "deb https://${APT_MIRROR}/ubuntu jammy-security main restricted universe multiverse" >> /etc/apt/sources.list && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends ffmpeg python3-pip curl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 设置 Hugging Face 镜像源环境变量
|
||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 先复制 requirements.txt 利用层缓存
|
||||
COPY ./backend/requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir -i ${PIP_INDEX} -r requirements.txt && \
|
||||
pip install --no-cache-dir -i ${PIP_INDEX} 'transformers[torch]>=4.23'
|
||||
|
||||
# 再复制应用代码
|
||||
COPY ./backend /app
|
||||
RUN pip install --no-cache-dir -i https://pypi.mirrors.ustc.edu.cn/simple -r requirements.txt
|
||||
RUN pip install --no-cache-dir -i https://pypi.mirrors.ustc.edu.cn/simple 'transformers[torch]>=4.23'
|
||||
|
||||
CMD ["python3", "main.py"]
|
||||
|
||||
@@ -25,6 +25,7 @@ cp .env.example backend/.env
|
||||
# 步骤 2: PyInstaller 打包,直接添加已存在的 .env 文件
|
||||
echo "开始 PyInstaller 打包..."
|
||||
pyinstaller \
|
||||
-y \
|
||||
--name BiliNoteBackend \
|
||||
--paths backend \
|
||||
--distpath ./BillNote_frontend/src-tauri/bin \
|
||||
|
||||
Reference in New Issue
Block a user