This commit is contained in:
2025-10-21 20:27:45 +08:00
parent fe76d14835
commit 6cf9d0a1ac
8 changed files with 70 additions and 2 deletions

2
.build/build-assets.sh Executable file → Normal file
View File

@@ -6,7 +6,7 @@ export NODE_OPTIONS="--max-old-space-size=8192"
cd assets
rm -rf build
yarn install --network-timeout 1000000
yarn version --new-version $1 --no-git-tag-version
# yarn version --new-version $1 --no-git-tag-version
yarn run build
# Copy the build files to the application directory

0
.build/entrypoint.sh Executable file → Normal file
View File

2
assets

Submodule assets updated: 7b8f6c02e9...921570f229

BIN
assets.zip Normal file

Binary file not shown.

54
build.sh Normal file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
set -e
# 1. 记录起始时间(用 %s 取整数秒,避免小数运算依赖 bc
start_seconds=$(date +%s)
start_datetime=$(date +"%Y-%m-%d %H:%M:%S")
echo "========================================"
echo "Build started at: $start_datetime"
echo "========================================"
# 2. 构建前端(统计耗时)
echo -e "\n[1/2] Starting frontend build..."
frontend_start=$(date +%s) # 前端开始时间(整数秒)
chmod +x ./.build/build-assets.sh
./.build/build-assets.sh
# 计算前端耗时(整数秒,直接用 bash 内置减法,无需 bc
frontend_end=$(date +%s)
frontend_duration=$((frontend_end - frontend_start))
echo "[1/2] Frontend build completed! (Time: ${frontend_duration}s)"
# 3. 构建后端(统计耗时)
echo -e "\n[2/2] Starting backend build..."
backend_start=$(date +%s) # 后端开始时间(整数秒)
# 获取 Git 版本和 Commit
export COMMIT_SHA=$(git rev-parse --short HEAD)
export VERSION=$(git describe --tags)
echo "Backend version: $VERSION, Commit: $COMMIT_SHA"
# 编译 Go 后端
go build -a -o cloudreve \
-ldflags "-s -w -X 'github.com/cloudreve/Cloudreve/v4/application/constants.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v4/application/constants.LastCommit=$COMMIT_SHA'"
# 计算后端耗时
backend_end=$(date +%s)
backend_duration=$((backend_end - backend_start))
echo "[2/2] Backend build completed! (Time: ${backend_duration}s)"
# 4. 总耗时统计(整数秒,直观易懂)
end_seconds=$(date +%s)
total_duration=$((end_seconds - start_seconds))
end_datetime=$(date +"%Y-%m-%d %H:%M:%S")
echo -e "\n========================================"
echo "Build successfully completed!"
echo "Total duration: ${total_duration}s"
echo "Started at: $start_datetime"
echo "Ended at: $end_datetime"
echo "========================================"

BIN
go1.25.0.linux-amd64.tar.gz Normal file

Binary file not shown.

10
node_modules/.yarn-integrity generated vendored Normal file
View File

@@ -0,0 +1,10 @@
{
"systemParams": "linux-x64-109",
"modulesFolders": [],
"flags": [],
"linkedModules": [],
"topLevelPatterns": [],
"lockfileEntries": {},
"files": [],
"artifacts": {}
}

4
yarn.lock Normal file
View File

@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1