feat: package docker deployment and publish flow

This commit is contained in:
theshy
2026-04-22 16:20:03 +08:00
parent 055474360e
commit 2146687dc6
178 changed files with 24318 additions and 20855 deletions

176
README_DEPLOY.md Normal file
View File

@ -0,0 +1,176 @@
# Docker Compose Deployment
This deployment runs the API and worker as two services from the same image.
Runtime state, credentials, staged videos, generated sessions, and the SQLite
database stay on the host through bind mounts.
## 1. Initialize Local Files
```bash
chmod +x scripts/init-docker-config.sh
./scripts/init-docker-config.sh
```
This creates these files if they do not already exist:
```text
.env
config/settings.json
runtime/cookies.json
runtime/upload_config.json
data/workspace/
```
## 2. Edit Required Secrets And IDs
Edit `.env`:
```env
GROQ_API_KEY=your_groq_key
OPENAI_API_KEY=your_openai_key_if_using_codex
COLLECTION_SEASON_ID_A=7196643
COLLECTION_SEASON_ID_B=7196624
```
Edit `runtime/cookies.json` and `runtime/upload_config.json` with real Bilibili
credentials and upload metadata.
`runtime/upload_config.json` also controls pure-video title, description,
dynamic text, and top-comment formatting. Existing deployments mount
`./runtime` from the host, so updating the image does not overwrite this file.
When you want to change output text, edit the host file directly.
Common output templates:
```json
{
"template": {
"title": "【{streamer} (歌曲纯享版)】 {date} 共{song_count}首歌",
"description": "{streamer} {date} 歌曲纯享版。\n\n完整歌单与时间轴见置顶评论。\n直播完整版{current_full_video_link}\n上次直播{previous_full_video_link}\n\n本视频为歌曲纯享切片适合只听歌曲。",
"dynamic": "{streamer} {date} 歌曲纯享版已发布。完整歌单见置顶评论。\n直播完整版{current_full_video_link}\n上次直播{previous_full_video_link}"
},
"comment_template": {
"split_header": "当前视频:歌曲纯享版:只保留本场直播中的歌曲片段,歌单见下方。\n直播完整版{current_full_video_link} (完整录播,含聊天/互动/完整流程)\n上次直播{previous_full_video_link} (上一场完整录播)",
"full_header": "当前视频:直播完整版:保留本场完整录播内容,歌曲时间轴见下方。\n歌曲纯享版{current_pure_video_link} (只听歌曲看这里)\n上次直播{previous_full_video_link} (上一场完整录播)",
"split_part_header": "P{part_index}:",
"full_part_header": "P{part_index}:",
"split_song_line": "{song_index}. {title}{artist_suffix}",
"split_text_song_line": "{song_index}. {song_text}",
"full_timeline_line": "{song_index}. {line_text}"
}
}
```
Supported comment variables:
- `{current_full_video_link}` / `{current_pure_video_link}`
- `{previous_full_video_link}` / `{previous_pure_video_link}`
- `{part_index}` / `{song_index}`
- `{title}` / `{artist}` / `{artist_suffix}` / `{song_text}` / `{line_text}`
If a comment header line contains an empty link variable, that whole line is
omitted. This prevents comments from showing blank `上次直播:` lines when the
previous live video cannot be found.
Provide the `biliup` binary at:
```text
runtime/biliup
```
It must be executable inside the container:
```bash
chmod +x runtime/biliup
```
The image installs the `codex` CLI for `song_detect.provider=codex`. Provide
Codex auth in one of these ways:
```text
OPENAI_API_KEY in .env
runtime/codex mounted to /root/.codex
```
## 3. Start
```bash
docker compose up -d --build
```
Open:
```text
http://127.0.0.1:8000
```
Drop videos into:
```text
data/workspace/stage/
```
## Common Commands
```bash
docker compose logs -f api
docker compose logs -f worker
docker compose restart worker
docker compose down
```
Run one scheduler cycle manually:
```bash
docker compose run --rm worker biliup-next run-once
```
Run doctor:
```bash
docker compose run --rm api biliup-next doctor
```
## Environment Overrides
`config/settings.json` is still the base configuration. Environment variables
override selected values at runtime.
The Compose file already forces container-safe paths such as
`/app/data/workspace` and `/app/runtime/cookies.json`, so an existing local
`config/settings.json` with host paths can still be mounted safely.
Generic format:
```text
BILIUP_NEXT__GROUP__FIELD=value
```
Examples:
```env
BILIUP_NEXT__PATHS__STAGE_DIR=/app/data/workspace/stage
BILIUP_NEXT__PUBLISH__BILIUP_PATH=/app/runtime/biliup
BILIUP_NEXT__PUBLISH__RETRY_SCHEDULE_MINUTES=[15,5,5,5,5]
```
Convenience aliases:
```env
GROQ_API_KEY=...
COLLECTION_SEASON_ID_A=7196643
COLLECTION_SEASON_ID_B=7196624
```
## Data Persistence
These host paths are mounted into the containers:
```text
./config -> /app/config
./runtime -> /app/runtime
./data/workspace -> /app/data/workspace
```
Do not store `cookies.json`, Groq keys, or generated workspace data in the image.
They should stay in the mounted host directories.