pull file
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled

This commit is contained in:
2026-02-11 23:32:56 +08:00
commit e519cac94e
656 changed files with 45058 additions and 0 deletions

171
docker/README.md Normal file
View File

@@ -0,0 +1,171 @@
# Docker 使用说明
<!-- TOC depthFrom:2 -->
- [1. 前期工作](#1-前期工作)
- [2. 方式一:一键脚本(推荐)](#2-方式一一键脚本推荐)
- [3. 方式二:手动 Docker Compose](#3-方式二手动-docker-compose)
- [3.1. 启动](#31-启动)
- [3.2. 其他命令参考](#32-其他命令参考)
- [4. 方式三手动Docker指令](#4-方式三手动docker指令)
- [4.1. Docker启动](#41-docker启动)
- [4.2. 其他指令参考](#42-其他指令参考)
- [4.3. 使用Watchtower更新容器](#43-使用watchtower更新容器)
- [5. 登录](#5-登录)
- [6. 添加 Bili 账号](#6-添加-bili-账号)
- [7. 自己构建镜像(非必须)](#7-自己构建镜像非必须)
- [8. 其他](#8-其他)
<!-- /TOC -->
## 1. 前期工作
```
apt-get update
apt-get install curl
```
## 2. 方式一:一键脚本(推荐)
```
bash <(curl -sSL https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/docker/install.sh)
```
## 3. 方式二:手动 Docker Compose
### 3.1. 启动
```
# 创建目录
mkdir bili_tool_web && cd bili_tool_web
# 下载
wget https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/docker/sample/docker-compose.yml
mkdir -p config
cd ./config
wget https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/main/docker/sample/config/cookies.json
cd ..
# 启动
docker compose up -d
# 查看启动日志
docker logs -f bili_tool_web
```
最终文件结构如下:
```
bili_tool_web
├── Logs
├── config
├──── cookies.json
└── docker-compose.yml
```
### 3.2. 其他命令参考
```
# 启动 docker-compose
docker compose up -d
# 停止 docker-compose
docker compose stop
# 查看实时日志
docker logs -f bili_tool_web
# 进入容器
docker exec -it bili_tool_web /bin/bash
# 手动更新容器
docker compose pull && docker compose up -d
```
## 4. 方式三手动Docker指令
### 4.1. Docker启动
```
# 创建目录
mkdir bili_tool_web && cd bili_tool_web
# 生成并运行容器
docker pull ghcr.io/raywangqvq/bili_tool_web
docker run -d --name="bili_tool_web" \
-p 22330:8080 \
-e TZ=Asia/Shanghai \
-v ./Logs:/app/Logs \
-v ./config:/app/config \
ghcr.io/raywangqvq/bili_tool_web
# 查看实时日志
docker logs -f bili_tool_web
```
其中,`cookie`需要替换为自己真实的cookie字符串
### 4.2. 其他指令参考
```
# 启动容器
docker start bili_tool_web
# 停止容器
docker stop bili_tool_web
# 重启容器
docker restart bili_tool_web
# 删除容器
docker rm bili_tool_web
# 进入容器
docker exec -it bili_tool_web /bin/bash
```
### 4.3. 使用Watchtower更新容器
```
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--run-once --cleanup \
bili_tool_web
```
## 5. 登录
- 默认用户:`admin`
- 默认密码:`BiliTool@2233`
首次登陆后,请到`Admin`页面修改密码。
## 6. 添加 Bili 账号
扫码进行账号添加。
![trigger](../docs/imgs/web-trigger-login.png)
![login](../docs/imgs/docker-login.png)
## 7. 自己构建镜像(非必须)
目前我提供和维护的镜像:
- DockerHub: `[zai7lou/bili_tool_web](https://hub.docker.com/repository/docker/zai7lou/bili_tool_web)`
- GitHub: `[bili_tool_web](https://github.com/RayWangQvQ/BiliBiliToolPro/pkgs/container/bili_tool_web)`
如果有需要(大部分都不需要),可以使用源码自己构建镜像,如下:
在有项目的Dockerfile的目录运行
`docker build -t TARGET_NAME .`
`TARGET_NAME`为镜像名称和版本,可以自己起个名字
## 8. 其他
代码编译和发布环境: mcr.microsoft.com/dotnet/sdk:8.0
代码运行环境: mcr.microsoft.com/dotnet/aspnet:8.0
如果下载`github`资源有问题,可以尝试添加加速器。

View File

@@ -0,0 +1,8 @@
echo "start to build"
# https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
# https://segmentfault.com/a/1190000021166703
# linux/arm/v6,linux/riscv64,linux/s390x,linux/ppc64le,linux/386,,linux/arm/v7 偶发异常,待进一步测试
echo "Start to build docker image with multi-arch"
# $image="zai7lou/bilibili_tool_pro"
# $version="0.0.5"
docker buildx build --tag "zai7lou/bilibili_tool_pro:0.0.5" --tag "zai7lou/bilibili_tool_pro:latest" --output "type=image,push=true" --platform linux/amd64,linux/arm64 ../..

View File

@@ -0,0 +1,8 @@
@echo off
REM start to build
echo Start to build docker image
@echo on
docker build --tag zai7lou/bilibili_tool_pro:latest ../..
@echo off
pause

View File

@@ -0,0 +1,10 @@
@echo off
REM start to build
REM https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
REM https://segmentfault.com/a/1190000021166703
echo Start to build docker image with amd64-arch
@echo on
docker buildx build --tag zai7lou/bilibili_tool_pro:latest --output "type=image,push=false" --platform linux/amd64 ../..
@echo off
pause

View File

@@ -0,0 +1,10 @@
@echo off
REM start to build
REM https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
REM https://segmentfault.com/a/1190000021166703
echo Start to build docker image with arm64-arch
@echo on
docker buildx build --platform linux/arm64 -o type=docker -t zai7lou/bilibili_tool ../..
@echo off
pause

17
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
set -o pipefail
echo "Starting BiliTool container..."
mkdir -p /app/config
echo "Running maintenance scripts..."
# 3.3.0 need migrate db file location to /app/config
if [ -f "/app/BiliBiliTool.db" ]; then
echo "[3.3.0] Migrate db file location to /app/config"
mv /app/BiliBiliTool.db /app/config/BiliBiliTool.db
fi
echo "Starting application..."
exec dotnet Ray.BiliBiliTool.Web.dll "$@"

337
docker/install.sh Normal file
View File

@@ -0,0 +1,337 @@
#!/usr/bin/env bash
###
# @Author: Ray zai7lou@outlook.com
# @Date: 2023-02-11 23:13:19
# @LastEditors: Ray zai7lou@outlook.com
# @LastEditTime: 2023-02-12 20:51:19
# @FilePath: \BiliBiliToolPro\docker\install.sh
# @Description:
###
set -e
set -u
set -o pipefail
echo ' ____ _ _____ _ '
echo ' | __ ) _| |_|_ _|__ ___ | | '
echo ' | _ \(_) (_) | |/ _ \ / _ \| | '
echo ' | |_) | | | | | | (_) | (_) | | '
echo ' |____/|_|_|_| |_|\___/ \___/|_| '
current_dir=$(pwd)
base_dir="${current_dir}/bili_tool_web"
github_proxy=""
github_branch="main"
remote_compose_url="${github_proxy}https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/refs/heads/${github_branch}/docker/sample/docker-compose.yml"
remote_ckJson_url="${github_proxy}https://raw.githubusercontent.com/RayWangQvQ/BiliBiliToolPro/refs/heads/${github_branch}/docker/sample/config/cookies.json"
docker_img_name="ghcr.io/raywangqvq/bili_tool_web"
container_name="bili_tool_web"
### infra
verbose=false
invocation='echo "" && say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
if [ -t 1 ] && command -v tput >/dev/null; then
ncolors=$(tput colors || echo 0)
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
bold="$(tput bold || echo)"
normal="$(tput sgr0 || echo)"
black="$(tput setaf 0 || echo)"
red="$(tput setaf 1 || echo)"
green="$(tput setaf 2 || echo)"
yellow="$(tput setaf 3 || echo)"
blue="$(tput setaf 4 || echo)"
magenta="$(tput setaf 5 || echo)"
cyan="$(tput setaf 6 || echo)"
white="$(tput setaf 7 || echo)"
fi
fi
say_verbose() {
if [ "$verbose" = true ]; then
# using stream 3 (defined in the beginning) to not interfere with stdout of functions
# which may be used as return value
printf "%b\n" "${cyan:-}$(date "+%Y-%m-%d %H:%M:%S")[VER]:${normal:-} $1" >&3
fi
}
say_info() {
printf "%b\n" "${green:-}$(date "+%Y-%m-%d %H:%M:%S")[INF]:$1${normal:-}" >&2
}
say_warning() {
printf "%b\n" "${yellow:-}$(date "+%Y-%m-%d %H:%M:%S")[WAR]:$1${normal:-}" >&3
}
say_err() {
printf "%b\n" "${red:-}$(date "+%Y-%m-%d %H:%M:%S")[ERR]:$1${normal:-}" >&2
}
machine_has() {
eval $invocation
command -v "$1" >/dev/null 2>&1
return $?
}
# args:
# remote_path - $1
get_http_header_curl() {
eval $invocation
local remote_path="$1"
curl_options="-I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 "
curl $curl_options "$remote_path" 2>&1 || return 1
return 0
}
# args:
# remote_path - $1
get_http_header_wget() {
eval $invocation
local remote_path="$1"
local wget_options="-q -S --spider --tries 5 "
# Store options that aren't supported on all wget implementations separately.
local wget_options_extra="--waitretry 2 --connect-timeout 15 "
local wget_result=''
wget $wget_options $wget_options_extra "$remote_path" 2>&1
wget_result=$?
if [[ $wget_result == 2 ]]; then
# Parsing of the command has failed. Exclude potentially unrecognized options and retry.
wget $wget_options "$remote_path" 2>&1
return $?
fi
return $wget_result
}
# Updates global variables $http_code and $download_error_msg
downloadcurl() {
eval $invocation
unset http_code
unset download_error_msg
local remote_path="$1"
local out_path="${2:-}"
local remote_path_with_credential="${remote_path}"
local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs "
local failed=false
if [ -z "$out_path" ]; then
curl $curl_options "$remote_path_with_credential" 2>&1 || failed=true
else
curl $curl_options -o "$out_path" "$remote_path_with_credential" 2>&1 || failed=true
fi
if [ "$failed" = true ]; then
local response=$(get_http_header_curl $remote_path)
http_code=$(echo "$response" | awk '/^HTTP/{print $2}' | tail -1)
download_error_msg="Unable to download $remote_path."
if [[ $http_code != 2* ]]; then
download_error_msg+=" Returned HTTP status code: $http_code."
fi
say_verbose "$download_error_msg"
return 1
fi
return 0
}
# Updates global variables $http_code and $download_error_msg
downloadwget() {
eval $invocation
unset http_code
unset download_error_msg
local remote_path="$1"
local out_path="${2:-}"
local remote_path_with_credential="${remote_path}"
local wget_options="--tries 20 "
# Store options that aren't supported on all wget implementations separately.
local wget_options_extra="--waitretry 2 --connect-timeout 15 "
local wget_result=''
if [ -z "$out_path" ]; then
wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1
wget_result=$?
else
wget $wget_options $wget_options_extra -O "$out_path" "$remote_path_with_credential" 2>&1
wget_result=$?
fi
if [[ $wget_result == 2 ]]; then
# Parsing of the command has failed. Exclude potentially unrecognized options and retry.
if [ -z "$out_path" ]; then
wget -q $wget_options -O - "$remote_path_with_credential" 2>&1
wget_result=$?
else
wget $wget_options -O "$out_path" "$remote_path_with_credential" 2>&1
wget_result=$?
fi
fi
if [[ $wget_result != 0 ]]; then
local disable_feed_credential=false
local response=$(get_http_header_wget $remote_path $disable_feed_credential)
http_code=$(echo "$response" | awk '/^ HTTP/{print $2}' | tail -1)
download_error_msg="Unable to download $remote_path."
if [[ $http_code != 2* ]]; then
download_error_msg+=" Returned HTTP status code: $http_code."
fi
say_verbose "$download_error_msg"
return 1
fi
return 0
}
# args:
# remote_path - $1
# [out_path] - $2 - stdout if not provided
download() {
eval $invocation
local remote_path="$1"
local out_path="${2:-}"
if [[ "$remote_path" != "http"* ]]; then
cp "$remote_path" "$out_path"
return $?
fi
local failed=false
local attempts=0
while [ $attempts -lt 3 ]; do
attempts=$((attempts + 1))
failed=false
if machine_has "curl"; then
downloadcurl "$remote_path" "$out_path" || failed=true
elif machine_has "wget"; then
downloadwget "$remote_path" "$out_path" || failed=true
else
say_err "Missing dependency: neither curl nor wget was found."
exit 1
fi
if [ "$failed" = false ] || [ $attempts -ge 3 ] || { [ ! -z $http_code ] && [ $http_code = "404" ]; }; then
break
fi
say_info "Download attempt #$attempts has failed: $http_code $download_error_msg"
say_info "Attempt #$((attempts + 1)) will start in $((attempts * 10)) seconds."
sleep $((attempts * 10))
done
if [ "$failed" = true ]; then
say_verbose "Download failed: $remote_path"
return 1
fi
return 0
}
createBaseDir() {
eval $invocation
mkdir -p $base_dir
cd $base_dir
}
installDocker() {
eval $invocation
if machine_has "docker"; then
say_info "已安装docker"
docker --version
return 0
else
say_warning "未安装docker尝试安装"
download "https://get.docker.com" ./get-docker.sh
chmod +x ./get-docker.sh
get-docker.sh
if machine_has "docker"; then
say_info "已安装docker"
docker --version
return 0
else
say_err "docker 安装失败,请手动安装成功后再执行该脚本"
exit 1
fi
fi
}
downloadResources() {
eval $invocation
say_info "开始下载资源"
# docker compose
[ -f "docker-compose.yml" ] || download $remote_compose_url ./docker-compose.yml
# ckJson
mkdir -p config
cd ./config
[ -f "cookies.json" ] || download $remote_ckJson_url ./cookies.json
chmod +x ./cookies.json
cd ..
ls -l
}
runContainer() {
eval $invocation
say_info "开始拉取镜像"
docker pull $docker_img_name
say_info "开始运行容器"
{
docker compose version && docker compose up -d
} || {
docker-compose version && docker-compose up -d
} || {
docker run -d --name="${container_name}" \
-p 22330:8080 \
-e TZ=Asia/Shanghai \
-v $base_dir/Logs:/app/Logs \
-v $base_dir/config:/app/config \
$docker_img_name
} || {
say_err "创建容器失败,请检查"
exit 1
}
}
checkResult() {
eval $invocation
say_info "检测容器运行情况"
docker ps --filter "name=${container_name}"
containerId=$(docker ps -q --filter "name=^${container_name}$")
if [ -n "$containerId" ]; then
docker logs ${container_name}
echo ""
echo "==============================================="
echo "Congratulations! 恭喜!"
echo "创建并运行${container_name}容器成功。"
echo "访问地址http:{ip}:22330"
echo "云服务器防火墙请自行开放22330端口"
echo "首次运行后,请执行扫码登录任务添加账号"
echo "Enjoy it~"
echo "==============================================="
else
echo ""
echo "请查看运行日志,确认容器是否正常运行,点击 Ctrl+c 退出日志追踪"
echo ""
docker logs -f ${container_name}
fi
}
main() {
installDocker
createBaseDir
downloadResources
runContainer
checkResult
}
main

View File

@@ -0,0 +1,4 @@
{
"BiliBiliCookies":[
]
}

View File

@@ -0,0 +1,14 @@
services:
bili_tool_web:
image: ghcr.io/raywangqvq/bili_tool_web
container_name: bili_tool_web
restart: unless-stopped
tty: true
volumes:
- ./Logs:/app/Logs
- ./config:/app/config
ports:
- "22330:8080"
environment:
TZ: "Asia/Shanghai"
DailyTaskConfig__Cron: "0 0 15 * * ?"