mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-06 20:42:52 +08:00
Merge pull request #302 from JefferyHcool/feature/optimize-build
feat(build): 全面优化打包流程,Docker 镜像自动发布到 GHCR
This commit is contained in:
334
.dockerignore
334
.dockerignore
@@ -1,321 +1,35 @@
|
|||||||
# Logs
|
# Git 和 IDE
|
||||||
logs
|
.git
|
||||||
*.log
|
.github
|
||||||
npm-debug.log*
|
.idea/
|
||||||
yarn-debug.log*
|
.vscode/
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
BiliNote/pnpm-lock.yaml
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Tauri 构建产物(非常大)
|
||||||
lib-cov
|
BillNote_frontend/src-tauri/target
|
||||||
|
BillNote_frontend/src-tauri/bin
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# 运行时数据
|
||||||
coverage
|
backend/data
|
||||||
*.lcov
|
backend/static
|
||||||
|
backend/models
|
||||||
|
backend/logs
|
||||||
|
backend/uploads
|
||||||
|
backend/*.db
|
||||||
|
backend/note_results
|
||||||
|
backend/bin/
|
||||||
|
|
||||||
# nyc test coverage
|
# 依赖和构建缓存
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
node_modules/
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
|
||||||
web_modules/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Optional stylelint cache
|
|
||||||
.stylelintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
.BiliNote-dev/*
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variable files
|
|
||||||
.env
|
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
.env.local
|
|
||||||
!.env.example
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
.parcel-cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
out
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# vuepress v2.x temp and cache directory
|
|
||||||
.temp
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# vitepress build output
|
|
||||||
**/.vitepress/dist
|
|
||||||
|
|
||||||
# vitepress cache directory
|
|
||||||
**/.vitepress/cache
|
|
||||||
|
|
||||||
# Docusaurus cache and generated files
|
|
||||||
.docusaurus
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
|
||||||
.vscode-test
|
|
||||||
|
|
||||||
# yarn v2
|
|
||||||
.yarn/cache
|
|
||||||
.yarn/unplugged
|
|
||||||
.yarn/build-state.yml
|
|
||||||
.yarn/install-state.gz
|
|
||||||
.pnp.*
|
|
||||||
# Byte-compiled / optimized / DLL files
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Distribution / packaging
|
|
||||||
.Python
|
|
||||||
build/
|
|
||||||
develop-eggs/
|
|
||||||
dist/
|
dist/
|
||||||
downloads/
|
build/
|
||||||
eggs/
|
*.tar
|
||||||
.eggs/
|
|
||||||
|
|
||||||
lib64/
|
|
||||||
parts/
|
|
||||||
sdist/
|
|
||||||
var/
|
|
||||||
wheels/
|
|
||||||
share/python-wheels/
|
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
.installed.cfg
|
|
||||||
*.egg
|
|
||||||
MANIFEST
|
|
||||||
|
|
||||||
# PyInstaller
|
# 环境文件
|
||||||
# Usually these files are written by a python script from a template
|
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
||||||
*.manifest
|
|
||||||
*.spec
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
pip-delete-this-directory.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
htmlcov/
|
|
||||||
.tox/
|
|
||||||
.nox/
|
|
||||||
.coverage
|
|
||||||
.coverage.*
|
|
||||||
.cache
|
|
||||||
nosetests.xml
|
|
||||||
coverage.xml
|
|
||||||
*.cover
|
|
||||||
*.py,cover
|
|
||||||
.hypothesis/
|
|
||||||
.pytest_cache/
|
|
||||||
cover/
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
*.pot
|
|
||||||
.idea/
|
|
||||||
# Django stuff:
|
|
||||||
*.log
|
|
||||||
local_settings.py
|
|
||||||
db.sqlite3
|
|
||||||
db.sqlite3-journal
|
|
||||||
|
|
||||||
# Flask stuff:
|
|
||||||
instance/
|
|
||||||
.webassets-cache
|
|
||||||
|
|
||||||
# Scrapy stuff:
|
|
||||||
.scrapy
|
|
||||||
|
|
||||||
# Sphinx documentation
|
|
||||||
docs/_build/
|
|
||||||
|
|
||||||
# PyBuilder
|
|
||||||
.pybuilder/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Jupyter Notebook
|
|
||||||
.ipynb_checkpoints
|
|
||||||
|
|
||||||
# IPython
|
|
||||||
profile_default/
|
|
||||||
ipython_config.py
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
|
||||||
# .python-version
|
|
||||||
|
|
||||||
# pipenv
|
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
||||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
||||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
||||||
# install all needed dependencies.
|
|
||||||
#Pipfile.lock
|
|
||||||
|
|
||||||
# UV
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
#uv.lock
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
||||||
# commonly ignored for libraries.
|
|
||||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
||||||
#poetry.lock
|
|
||||||
|
|
||||||
# pdm
|
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
||||||
#pdm.lock
|
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
||||||
# in version control.
|
|
||||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
||||||
.pdm.toml
|
|
||||||
.pdm-python
|
|
||||||
.pdm-build/
|
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
||||||
__pypackages__/
|
|
||||||
|
|
||||||
# Celery stuff
|
|
||||||
celerybeat-schedule
|
|
||||||
celerybeat.pid
|
|
||||||
|
|
||||||
# SageMath parsed files
|
|
||||||
*.sage.py
|
|
||||||
|
|
||||||
# Environments
|
|
||||||
.env
|
.env
|
||||||
.venv
|
.env.local
|
||||||
env/
|
.env.*.local
|
||||||
venv/
|
!.env.example
|
||||||
ENV/
|
|
||||||
env.bak/
|
|
||||||
venv.bak/
|
|
||||||
|
|
||||||
# Spyder project settings
|
|
||||||
.spyderproject
|
|
||||||
.spyproject
|
|
||||||
|
|
||||||
# Rope project settings
|
|
||||||
.ropeproject
|
|
||||||
|
|
||||||
# mkdocs documentation
|
|
||||||
/site
|
|
||||||
|
|
||||||
# mypy
|
|
||||||
.mypy_cache/
|
|
||||||
.dmypy.json
|
|
||||||
dmypy.json
|
|
||||||
|
|
||||||
# Pyre type checker
|
|
||||||
.pyre/
|
|
||||||
|
|
||||||
# pytype static type analyzer
|
|
||||||
.pytype/
|
|
||||||
|
|
||||||
# Cython debug symbols
|
|
||||||
cython_debug/
|
|
||||||
|
|
||||||
# PyCharm
|
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
||||||
#.idea/
|
|
||||||
|
|
||||||
# Ruff stuff:
|
|
||||||
.ruff_cache/
|
|
||||||
|
|
||||||
# PyPI configuration file
|
|
||||||
.pypirc
|
|
||||||
/backend/data/*
|
|
||||||
/backend/static/*
|
|
||||||
/backend/note_tasks.db
|
|
||||||
/backend/bin/
|
|
||||||
/backend/logs/
|
|
||||||
/backend/note_results
|
|
||||||
/backend/models
|
|
||||||
/backend/.idea/*
|
|
||||||
/backend/bili_note.db
|
|
||||||
/backend/uploads/*
|
|
||||||
/BiliNote_frontend/.idea/*
|
|
||||||
|
|||||||
101
.github/workflows/docker-build.yml
vendored
101
.github/workflows/docker-build.yml
vendored
@@ -1,76 +1,73 @@
|
|||||||
name: Build Complete Docker Image
|
name: Build and Publish Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # 在推送 tag 时触发 (如 v1.0.0)
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Extract Version from Tag
|
|
||||||
id: get_version
|
|
||||||
run: |
|
|
||||||
# 获取 tag 名称 (如 refs/tags/v1.0.0 -> v1.0.0)
|
|
||||||
VERSION=${GITHUB_REF#refs/tags/}
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "Tag version: $VERSION"
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Log in to GitHub Container Registry
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
VERSION="${{ steps.get_version.outputs.version }}"
|
|
||||||
IMAGE_NAME="bilinote:${VERSION}"
|
|
||||||
|
|
||||||
echo "Building image: ${IMAGE_NAME}"
|
|
||||||
|
|
||||||
# 构建镜像
|
|
||||||
docker build -f Dockerfile.complete -t ${IMAGE_NAME} .
|
|
||||||
|
|
||||||
# 保存镜像为 tar 文件
|
|
||||||
docker save ${IMAGE_NAME} -o bilinote-${VERSION}.tar
|
|
||||||
|
|
||||||
# 显示镜像信息
|
|
||||||
echo "Image built successfully!"
|
|
||||||
docker images bilinote:${VERSION}
|
|
||||||
|
|
||||||
- name: Upload Docker Image Artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: bilinote-${{ steps.get_version.outputs.version }}
|
registry: ${{ env.REGISTRY }}
|
||||||
path: bilinote-${{ steps.get_version.outputs.version }}.tar
|
username: ${{ github.actor }}
|
||||||
retention-days: 90
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=sha,prefix=
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile.complete
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
||||||
- name: Generate Usage Instructions
|
- name: Generate Usage Instructions
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.get_version.outputs.version }}"
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "Docker Image Build Complete!"
|
echo "Docker Image Published!"
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo ""
|
echo ""
|
||||||
echo "Image Name: bilinote:${VERSION}"
|
echo "Pull the image:"
|
||||||
echo "Artifact: bilinote-${VERSION}.tar"
|
echo " docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To use this Docker image:"
|
echo "Run the container:"
|
||||||
echo "1. Download the artifact from this workflow run"
|
echo " docker run -d -p 80:80 \\"
|
||||||
echo "2. Load the image:"
|
echo " -v bilinote-data:/app/backend/data \\"
|
||||||
echo " docker load < bilinote-${VERSION}.tar"
|
echo " --name bilinote \\"
|
||||||
echo "3. Run the container:"
|
echo " ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
||||||
echo " docker run -d -p 80:80 --name bilinote bilinote:${VERSION}"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Or with environment variables:"
|
echo "Access the application at: http://localhost"
|
||||||
echo " docker run -d -p 80:80 \\"
|
|
||||||
echo " -e BACKEND_PORT=8483 \\"
|
|
||||||
echo " -e BACKEND_HOST=0.0.0.0 \\"
|
|
||||||
echo " -v /path/to/data:/app/backend/data \\"
|
|
||||||
echo " --name bilinote bilinote:${VERSION}"
|
|
||||||
echo ""
|
|
||||||
echo "Access the application at: http://localhost:80"
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
|
|||||||
68
.github/workflows/main.yml
vendored
68
.github/workflows/main.yml
vendored
@@ -6,25 +6,38 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*' # 发布 tag 时触发
|
- 'v*' # 发布 tag 时触发
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [macos-latest, windows-latest]
|
include:
|
||||||
|
- platform: macos-latest
|
||||||
|
- platform: ubuntu-22.04
|
||||||
|
- platform: windows-latest
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 设置 Python 环境
|
# Linux 系统依赖(Tauri 需要)
|
||||||
|
- name: Install Linux Dependencies
|
||||||
|
if: matrix.platform == 'ubuntu-22.04'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
# 设置 Python 环境(带 pip 缓存)
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
python-version: '3.11'
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: backend/requirements.txt
|
||||||
|
|
||||||
# 安装 Python 依赖并执行你的 build.sh
|
# 安装 Python 依赖并执行构建
|
||||||
- name: Install Python dependencies & Build backend
|
- name: Install Python dependencies & Build backend
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -38,30 +51,57 @@ jobs:
|
|||||||
./backend/build.sh
|
./backend/build.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 设置 Node 环境 + 安装前端依赖
|
# 设置 pnpm
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 'latest'
|
||||||
|
|
||||||
|
# 设置 Node 环境(带 pnpm 缓存)
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
cache: 'pnpm'
|
||||||
|
cache-dependency-path: BillNote_frontend/pnpm-lock.yaml
|
||||||
|
|
||||||
- name: Enable Corepack + Install pnpm
|
- name: Install frontend dependencies
|
||||||
working-directory: BillNote_frontend
|
working-directory: BillNote_frontend
|
||||||
run: |
|
run: pnpm install --frozen-lockfile
|
||||||
corepack enable
|
|
||||||
pnpm install
|
|
||||||
|
|
||||||
# 设置 Rust 环境
|
# 设置 Rust 环境
|
||||||
- name: Set up Rust
|
- name: Set up Rust
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
# Cargo 缓存
|
||||||
|
- name: Cache Cargo
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
BillNote_frontend/src-tauri/target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('BillNote_frontend/src-tauri/Cargo.lock') }}
|
||||||
|
restore-keys: ${{ runner.os }}-cargo-
|
||||||
|
|
||||||
# 打包 Tauri 应用
|
# 打包 Tauri 应用
|
||||||
- name: Build Tauri App
|
- name: Build Tauri App
|
||||||
working-directory: BillNote_frontend
|
working-directory: BillNote_frontend
|
||||||
run: pnpm tauri build
|
run: pnpm tauri build
|
||||||
|
|
||||||
# 可选:上传构建产物
|
# 生成 SHA256 校验和
|
||||||
|
- name: Generate Checksums
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd BillNote_frontend/src-tauri/target/release/bundle/
|
||||||
|
find . -type f \( -name "*.dmg" -o -name "*.msi" -o -name "*.deb" -o -name "*.AppImage" \) -exec sha256sum {} \; > checksums.sha256 || true
|
||||||
|
|
||||||
|
# 上传构建产物
|
||||||
- name: Upload Desktop Bundle
|
- name: Upload Desktop Bundle
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: app-${{ matrix.platform }}
|
name: app-${{ matrix.platform }}
|
||||||
path: BillNote_frontend/src-tauri/target/release/bundle/
|
path: |
|
||||||
|
BillNote_frontend/src-tauri/target/release/bundle/
|
||||||
|
|||||||
@@ -1,25 +1,23 @@
|
|||||||
# === 前端构建阶段 ===
|
# === 前端构建阶段 ===
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
# 安装 pnpm
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
RUN npm install -g pnpm
|
|
||||||
|
|
||||||
# 设置工作目录
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 拷贝前端源码
|
# 先复制 lockfile 利用依赖层缓存
|
||||||
COPY ./BillNote_frontend /app
|
COPY ./BillNote_frontend/package.json ./BillNote_frontend/pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
# 安装依赖并构建
|
# 再复制源代码并构建
|
||||||
RUN pnpm install && pnpm run build
|
COPY ./BillNote_frontend/ ./
|
||||||
|
RUN pnpm run build
|
||||||
|
|
||||||
# --- 阶段2:使用 nginx 作为静态服务器 ---
|
# --- 阶段2:使用 nginx 作为静态服务器 ---
|
||||||
FROM nginx:1.25-alpine
|
FROM nginx:1.25-alpine
|
||||||
|
|
||||||
# 删除默认配置(可选)
|
|
||||||
RUN rm -rf /etc/nginx/conf.d/default.conf
|
RUN rm -rf /etc/nginx/conf.d/default.conf
|
||||||
COPY ./BillNote_frontend/deploy/default.conf /etc/nginx/conf.d/default.conf
|
COPY ./BillNote_frontend/deploy/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
|
||||||
# 拷贝构建产物
|
# 拷贝构建产物
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|||||||
@@ -1,41 +1,56 @@
|
|||||||
# === 阶段1:构建 Backend ===
|
# === 阶段1:构建 Backend ===
|
||||||
FROM python:3.11-slim AS backend-builder
|
FROM python:3.11-slim AS backend-builder
|
||||||
|
|
||||||
|
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 && \
|
RUN rm -f /etc/apt/sources.list && \
|
||||||
rm -rf /etc/apt/sources.list.d/* && \
|
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://${APT_MIRROR}/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://${APT_MIRROR}/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-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y ffmpeg && \
|
apt-get install -y --no-install-recommends ffmpeg && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV PATH="/usr/bin:${PATH}"
|
ENV PATH="/usr/bin:${PATH}"
|
||||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||||
|
|
||||||
WORKDIR /tmp/backend
|
WORKDIR /tmp/backend
|
||||||
|
|
||||||
|
# 先复制 requirements.txt 利用层缓存
|
||||||
|
COPY ./backend/requirements.txt /tmp/backend/requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -i ${PIP_INDEX} -r requirements.txt
|
||||||
|
|
||||||
COPY ./backend /tmp/backend
|
COPY ./backend /tmp/backend
|
||||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
|
||||||
|
|
||||||
# === 阶段2:构建 Frontend ===
|
# === 阶段2:构建 Frontend ===
|
||||||
FROM node:18-alpine AS frontend-builder
|
FROM node:18-alpine AS frontend-builder
|
||||||
|
|
||||||
RUN npm install -g pnpm
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
WORKDIR /tmp/frontend
|
WORKDIR /tmp/frontend
|
||||||
|
|
||||||
|
# 先复制 lockfile 利用依赖层缓存
|
||||||
|
COPY ./BillNote_frontend/package.json ./BillNote_frontend/pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
COPY ./BillNote_frontend /tmp/frontend
|
COPY ./BillNote_frontend /tmp/frontend
|
||||||
RUN pnpm install && pnpm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
# === 阶段3:完整应用镜像 ===
|
# === 阶段3:完整应用镜像 ===
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||||
|
|
||||||
# 安装必要的运行时依赖
|
# 安装必要的运行时依赖
|
||||||
RUN rm -f /etc/apt/sources.list && \
|
RUN rm -f /etc/apt/sources.list && \
|
||||||
rm -rf /etc/apt/sources.list.d/* && \
|
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://${APT_MIRROR}/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://${APT_MIRROR}/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-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y ffmpeg nginx supervisor procps && \
|
apt-get install -y --no-install-recommends ffmpeg nginx supervisor procps && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV PATH="/usr/bin:${PATH}"
|
ENV PATH="/usr/bin:${PATH}"
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -104,9 +104,30 @@ sudo apt install ffmpeg
|
|||||||
|
|
||||||
### 🐳 使用 Docker 一键部署
|
### 🐳 使用 Docker 一键部署
|
||||||
|
|
||||||
确保你已安装 Docker 和 Docker Compose:
|
确保你已安装 Docker,然后直接拉取预构建镜像运行:
|
||||||
|
|
||||||
[docker 部署](https://github.com/JefferyHcool/bilinote-deploy/blob/master/README.md)
|
```bash
|
||||||
|
# 拉取最新镜像
|
||||||
|
docker pull ghcr.io/jefferyhcool/bilinote:latest
|
||||||
|
|
||||||
|
# 运行容器
|
||||||
|
docker run -d -p 80:80 \
|
||||||
|
-v bilinote-data:/app/backend/data \
|
||||||
|
--name bilinote \
|
||||||
|
ghcr.io/jefferyhcool/bilinote:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
访问:`http://localhost`
|
||||||
|
|
||||||
|
也可以使用 docker-compose 本地构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 标准部署
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# GPU 加速部署(需要 NVIDIA GPU)
|
||||||
|
docker-compose -f docker-compose.gpu.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
## 🧠 TODO
|
## 🧠 TODO
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,27 @@
|
|||||||
FROM python:3.11-slim
|
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 && \
|
RUN rm -f /etc/apt/sources.list && \
|
||||||
rm -rf /etc/apt/sources.list.d/* && \
|
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://${APT_MIRROR}/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://${APT_MIRROR}/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-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y ffmpeg && \
|
apt-get install -y --no-install-recommends ffmpeg curl && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# 确保 PATH 中包含 ffmpeg 路径(可选)
|
|
||||||
ENV PATH="/usr/bin:${PATH}"
|
ENV PATH="/usr/bin:${PATH}"
|
||||||
|
|
||||||
# 设置 Hugging Face 镜像源环境变量
|
|
||||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||||
|
|
||||||
WORKDIR /app
|
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
|
COPY ./backend /app
|
||||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
|
||||||
|
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "main.py"]
|
||||||
|
|||||||
@@ -1,16 +1,27 @@
|
|||||||
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
|
||||||
|
|
||||||
RUN apt update && \
|
ARG APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||||
apt install -y ffmpeg python3-pip && \
|
ARG PIP_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
apt clean all && \
|
|
||||||
|
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/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# 设置 Hugging Face 镜像源环境变量
|
|
||||||
ENV HF_ENDPOINT=https://hf-mirror.com
|
ENV HF_ENDPOINT=https://hf-mirror.com
|
||||||
|
|
||||||
WORKDIR /app
|
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
|
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"]
|
CMD ["python3", "main.py"]
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ cp .env.example backend/.env
|
|||||||
# 步骤 2: PyInstaller 打包,直接添加已存在的 .env 文件
|
# 步骤 2: PyInstaller 打包,直接添加已存在的 .env 文件
|
||||||
echo "开始 PyInstaller 打包..."
|
echo "开始 PyInstaller 打包..."
|
||||||
pyinstaller \
|
pyinstaller \
|
||||||
|
-y \
|
||||||
--name BiliNoteBackend \
|
--name BiliNoteBackend \
|
||||||
--paths backend \
|
--paths backend \
|
||||||
--distpath ./BillNote_frontend/src-tauri/bin \
|
--distpath ./BillNote_frontend/src-tauri/bin \
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: backend/Dockerfile.gpu
|
dockerfile: backend/Dockerfile.gpu
|
||||||
|
args:
|
||||||
|
APT_MIRROR: ${APT_MIRROR:-mirrors.tuna.tsinghua.edu.cn}
|
||||||
|
PIP_INDEX: ${PIP_INDEX:-https://pypi.tuna.tsinghua.edu.cn/simple}
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: backend/Dockerfile
|
dockerfile: backend/Dockerfile
|
||||||
|
args:
|
||||||
|
APT_MIRROR: ${APT_MIRROR:-mirrors.tuna.tsinghua.edu.cn}
|
||||||
|
PIP_INDEX: ${PIP_INDEX:-https://pypi.tuna.tsinghua.edu.cn/simple}
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user