mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-19 02:18:25 +08:00
feat: introduce WeKnora Lite edition with lightweight configuration and deployment
- Added a new `.env.lite.example` file for the Lite version, providing a minimal configuration template. - Updated `.env.example` to remove deprecated variables and include new Docreader settings. - Enhanced Docker configurations to support the Lite version, including a new Dockerfile for the Docreader service. - Introduced a Makefile target for building and running the Lite version, along with packaging capabilities. - Created GitHub workflows for building and releasing Lite binaries, including Homebrew formula support. - Implemented a new service file for managing the Lite version as a system service. This update enables a streamlined, single-binary deployment of WeKnora, reducing external dependencies and simplifying setup.
This commit is contained in:
@@ -137,13 +137,13 @@ jobs:
|
||||
platform: linux/arm64
|
||||
runs: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.runs }}
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
id: setup-buildx
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
@@ -172,23 +172,6 @@ jobs:
|
||||
# 显示版本信息
|
||||
./scripts/get_version.sh info
|
||||
|
||||
- name: Build Cache for Docker
|
||||
uses: actions/cache@v4
|
||||
id: cache
|
||||
with:
|
||||
path: go-pkg-mod
|
||||
key: ${{ env.PLATFORM_PAIR }}-go-build-cache-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Inject go-build-cache
|
||||
uses: reproducible-containers/buildkit-cache-dance@v3
|
||||
with:
|
||||
builder: ${{ steps.setup-buildx.outputs.name }}
|
||||
cache-map: |
|
||||
{
|
||||
"go-pkg-mod": "/go/pkg/mod"
|
||||
}
|
||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||
|
||||
- name: Build app Image
|
||||
id: build
|
||||
uses: docker/build-push-action@v3
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
name: Release Lite Binaries
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag (e.g. v0.2.0)"
|
||||
required: true
|
||||
|
||||
concurrency:
|
||||
group: release-lite-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.24"
|
||||
NODE_VERSION: "22"
|
||||
|
||||
jobs:
|
||||
# ── 1. Build frontend once, share as artifact ──
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Build frontend
|
||||
working-directory: frontend
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist/
|
||||
retention-days: 1
|
||||
|
||||
# ── 2. Build Go binary per platform (native CGO) ──
|
||||
build-binary:
|
||||
needs: build-frontend
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
- os: ubuntu-24.04-arm
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
- os: macos-13
|
||||
goos: darwin
|
||||
goarch: amd64
|
||||
- os: macos-14
|
||||
goos: darwin
|
||||
goarch: arm64
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: web/
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "Building ${VERSION} for ${{ matrix.goos }}/${{ matrix.goarch }}"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export EDITION=lite
|
||||
eval "$(./scripts/get_version.sh env)"
|
||||
LDFLAGS="-w -s $(./scripts/get_version.sh ldflags)"
|
||||
export CGO_CFLAGS="-Wno-deprecated-declarations"
|
||||
if [ "${{ matrix.goos }}" = "darwin" ]; then
|
||||
export CGO_LDFLAGS="-Wl,-no_warn_duplicate_libraries"
|
||||
fi
|
||||
go build -tags "sqlite_fts5" -ldflags="${LDFLAGS}" \
|
||||
-o WeKnora-lite ./cmd/server
|
||||
|
||||
- name: Package tarball
|
||||
run: |
|
||||
ARCHIVE="WeKnora-lite_${{ steps.ver.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||
mkdir -p "${ARCHIVE}/web"
|
||||
cp WeKnora-lite "${ARCHIVE}/"
|
||||
cp -r web/* "${ARCHIVE}/web/"
|
||||
cp .env.lite.example "${ARCHIVE}/"
|
||||
cp docs/LITE.md "${ARCHIVE}/README.md"
|
||||
if [ -d config ]; then
|
||||
cp -r config "${ARCHIVE}/config"
|
||||
fi
|
||||
if [ -d migrations/sqlite ]; then
|
||||
mkdir -p "${ARCHIVE}/migrations/sqlite"
|
||||
cp -r migrations/sqlite/* "${ARCHIVE}/migrations/sqlite/"
|
||||
fi
|
||||
if [ -f deploy/weknora-lite.service ]; then
|
||||
cp deploy/weknora-lite.service "${ARCHIVE}/"
|
||||
fi
|
||||
tar czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
|
||||
shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: |
|
||||
WeKnora-lite_*.tar.gz
|
||||
WeKnora-lite_*.tar.gz.sha256
|
||||
retention-days: 3
|
||||
|
||||
# ── 3. Create GitHub Release ──
|
||||
release:
|
||||
needs: build-binary
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
cat > notes.md << 'NOTES'
|
||||
## WeKnora Lite ${{ steps.ver.outputs.version }}
|
||||
|
||||
单二进制部署,零外部依赖(无需 Docker / PostgreSQL / Redis)。
|
||||
|
||||
### 快速开始
|
||||
|
||||
```bash
|
||||
# 1. 解压
|
||||
tar xzf WeKnora-lite_${{ steps.ver.outputs.version }}_<os>_<arch>.tar.gz
|
||||
cd WeKnora-lite_${{ steps.ver.outputs.version }}_<os>_<arch>
|
||||
|
||||
# 2. 配置
|
||||
cp .env.lite.example .env.lite
|
||||
# 编辑 .env.lite,至少确认 OLLAMA_BASE_URL 正确
|
||||
|
||||
# 3. 启动 Ollama(如尚未运行)
|
||||
ollama serve &
|
||||
ollama pull qwen2.5:7b
|
||||
ollama pull nomic-embed-text
|
||||
|
||||
# 4. 运行
|
||||
set -a && source .env.lite && set +a
|
||||
./WeKnora-lite
|
||||
# 访问 http://localhost:8080
|
||||
```
|
||||
|
||||
### 平台支持
|
||||
|
||||
| 文件 | 平台 |
|
||||
|------|------|
|
||||
| `WeKnora-lite_*_linux_amd64.tar.gz` | Linux x86_64 |
|
||||
| `WeKnora-lite_*_linux_arm64.tar.gz` | Linux ARM64 |
|
||||
| `WeKnora-lite_*_darwin_amd64.tar.gz` | macOS Intel |
|
||||
| `WeKnora-lite_*_darwin_arm64.tar.gz` | macOS Apple Silicon |
|
||||
|
||||
详细文档见 [LITE.md](docs/LITE.md)。
|
||||
NOTES
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh release create "${{ steps.ver.outputs.version }}" \
|
||||
--title "WeKnora Lite ${{ steps.ver.outputs.version }}" \
|
||||
--notes-file notes.md \
|
||||
WeKnora-lite_*.tar.gz \
|
||||
WeKnora-lite_*.tar.gz.sha256
|
||||
|
||||
# ── 4. Update Homebrew Formula ──
|
||||
update-homebrew:
|
||||
needs: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Wait for release assets to be available
|
||||
run: sleep 15
|
||||
|
||||
- name: Update Formula
|
||||
run: ./scripts/update-homebrew-formula.sh "${{ steps.ver.outputs.version }}"
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add Formula/weknora-lite.rb
|
||||
if git diff --cached --quiet; then
|
||||
echo "No changes to Formula"
|
||||
else
|
||||
git commit -m "formula: update weknora-lite to ${{ steps.ver.outputs.version }}"
|
||||
git push origin main
|
||||
fi
|
||||
Reference in New Issue
Block a user