From 811f8199e0a88f093d86ef9b2f7774bb071f61b6 Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Sun, 10 May 2026 15:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=E5=BC=80=E5=8F=91=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E4=B8=8E=E5=85=A8=E9=87=8F=E9=83=A8=E7=BD=B2=EF=BC=8C?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E6=A0=B7=E5=BC=8F=E8=BF=AD=E4=BB=A3=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E8=B4=9F=E6=8B=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Constraint: 需要保留公网可见的真实部署路径,同时降低日常样式改动的部署成本 Rejected: 仅保留 --fast | 不会重建镜像,无法可靠看到代码/样式变更 Confidence: high Scope-risk: narrow Directive: 日常页面/样式迭代优先使用 --dev-deploy,资源或日志更新再使用 --full-deploy Tested: bash -n scripts/deploy-homepage.sh; scripts/deploy-homepage.sh --help; ./scripts/deploy-homepage.sh --dev-deploy; ./scripts/deploy-homepage.sh --full-deploy Not-tested: 生产域名切换后的反代行为 --- scripts/deploy-homepage.sh | 142 ++++++++++++++++++++++++++++++++- src/content/seafile/index.json | 20 +++-- src/content/shares/index.json | 10 +-- src/pages/index.astro | 2 +- 4 files changed, 155 insertions(+), 19 deletions(-) diff --git a/scripts/deploy-homepage.sh b/scripts/deploy-homepage.sh index 0639469..03f2753 100755 --- a/scripts/deploy-homepage.sh +++ b/scripts/deploy-homepage.sh @@ -36,6 +36,14 @@ RUN_LOCAL_REBUILD="${RUN_LOCAL_REBUILD:-true}" # 默认值:true RUN_STATIC_ASSET_SYNC="${RUN_STATIC_ASSET_SYNC:-true}" +# 是否执行日志同步 +# 默认值:true +RUN_LOG_SYNC="${RUN_LOG_SYNC:-true}" + +# 刷新 Docker 服务时是否强制重新构建镜像 +# 默认值:true +DOCKER_FORCE_BUILD="${DOCKER_FORCE_BUILD:-true}" + # 锁文件路径,避免定时任务重入 # 默认值:/tmp/personal-homepage-deploy.lock LOCK_FILE="${LOCK_FILE:-/tmp/personal-homepage-deploy.lock}" @@ -53,6 +61,33 @@ fail() { exit 1 } +usage() { + cat <<'EOF' +用法: + deploy-homepage.sh [options] + +选项: + --preset 使用预设部署档位 + --dev-deploy 等价于 --preset dev + --full-deploy 等价于 --preset full + --run-static-asset-sync 是否同步静态资源 + --run-log-sync 是否同步日志目录 + --run-local-rebuild 是否在宿主机执行 npm run rebuild + --docker-force-build docker compose up 时是否加 --build + --rsync-delete rsync 时是否启用 --delete + --fast 快速模式(仅刷新容器,不做同步与宿主机 rebuild) + -h, --help 显示帮助 + +说明: + - 预设档位: + dev = 仅代码/样式部署(不做静态资源同步与日志同步;仍会 docker --build) + full = 全量部署(静态资源 + 日志 + 宿主机 rebuild + docker --build) + fast = 仅快速刷新容器(不做同步、不本地 rebuild、且不 docker --build) + - 命令行参数优先级高于环境变量。 + - 布尔值支持: true/false/1/0/yes/no/on/off +EOF +} + require_command() { command -v "$1" >/dev/null 2>&1 || fail "缺少命令: $1" } @@ -64,6 +99,93 @@ is_true() { esac } +parse_args() { + while [[ $# -gt 0 ]]; do + case "$1" in + --preset) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + case "${2,,}" in + dev) + RUN_STATIC_ASSET_SYNC=false + RUN_LOG_SYNC=false + RUN_LOCAL_REBUILD=false + DOCKER_FORCE_BUILD=true + ;; + full) + RUN_STATIC_ASSET_SYNC=true + RUN_LOG_SYNC=true + RUN_LOCAL_REBUILD=true + DOCKER_FORCE_BUILD=true + ;; + fast) + RUN_STATIC_ASSET_SYNC=false + RUN_LOG_SYNC=false + RUN_LOCAL_REBUILD=false + DOCKER_FORCE_BUILD=false + ;; + *) + fail "不支持的 preset: $2(可选: dev|full|fast)" + ;; + esac + shift 2 + ;; + --dev-deploy) + RUN_STATIC_ASSET_SYNC=false + RUN_LOG_SYNC=false + RUN_LOCAL_REBUILD=false + DOCKER_FORCE_BUILD=true + shift + ;; + --full-deploy) + RUN_STATIC_ASSET_SYNC=true + RUN_LOG_SYNC=true + RUN_LOCAL_REBUILD=true + DOCKER_FORCE_BUILD=true + shift + ;; + --run-static-asset-sync) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + RUN_STATIC_ASSET_SYNC="$2" + shift 2 + ;; + --run-log-sync) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + RUN_LOG_SYNC="$2" + shift 2 + ;; + --run-local-rebuild) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + RUN_LOCAL_REBUILD="$2" + shift 2 + ;; + --docker-force-build) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + DOCKER_FORCE_BUILD="$2" + shift 2 + ;; + --rsync-delete) + [[ $# -ge 2 ]] || fail "参数缺少值: $1" + RSYNC_DELETE="$2" + shift 2 + ;; + --fast) + RUN_STATIC_ASSET_SYNC=false + RUN_LOG_SYNC=false + RUN_LOCAL_REBUILD=false + DOCKER_FORCE_BUILD=false + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + fail "未知参数: $1(使用 --help 查看可用参数)" + ;; + esac + done +} + sync_logs() { mkdir -p "$LOG_TARGET_DIR" @@ -108,7 +230,11 @@ refresh_docker_service() { log "刷新 Docker 服务: $DOCKER_SERVICE_NAME" ( cd "$SITE_DIR" - docker compose -f "$DOCKER_COMPOSE_FILE" up -d --build "$DOCKER_SERVICE_NAME" + if is_true "$DOCKER_FORCE_BUILD"; then + docker compose -f "$DOCKER_COMPOSE_FILE" up -d --build "$DOCKER_SERVICE_NAME" + else + docker compose -f "$DOCKER_COMPOSE_FILE" up -d "$DOCKER_SERVICE_NAME" + fi ) } @@ -135,8 +261,10 @@ main_impl() { log "DOCKER_COMPOSE_FILE=$DOCKER_COMPOSE_FILE" log "DOCKER_SERVICE_NAME=$DOCKER_SERVICE_NAME" log "RSYNC_DELETE=$RSYNC_DELETE" + log "RUN_LOG_SYNC=$RUN_LOG_SYNC" log "RUN_STATIC_ASSET_SYNC=$RUN_STATIC_ASSET_SYNC" log "RUN_LOCAL_REBUILD=$RUN_LOCAL_REBUILD" + log "DOCKER_FORCE_BUILD=$DOCKER_FORCE_BUILD" log "LOCK_FILE=$LOCK_FILE" if is_true "$RUN_STATIC_ASSET_SYNC"; then @@ -145,7 +273,11 @@ main_impl() { log "跳过静态资源同步(RUN_STATIC_ASSET_SYNC=false)" fi - sync_logs + if is_true "$RUN_LOG_SYNC"; then + sync_logs + else + log "跳过日志同步(RUN_LOG_SYNC=false)" + fi if is_true "$RUN_LOCAL_REBUILD"; then run_local_rebuild @@ -159,9 +291,11 @@ main_impl() { } main() { + parse_args "$@" + if ! command -v flock >/dev/null 2>&1; then log "未找到 flock,跳过锁保护" - main_impl "$@" + main_impl return 0 fi @@ -173,7 +307,7 @@ main() { fi log "已获取部署锁: $LOCK_FILE" - main_impl "$@" + main_impl } main "$@" diff --git a/src/content/seafile/index.json b/src/content/seafile/index.json index 6345e14..af57909 100644 --- a/src/content/seafile/index.json +++ b/src/content/seafile/index.json @@ -1,12 +1,12 @@ { "projects": [ { - "project_repo": "basil/personal-homepage", + "project_repo": "basil/biography-of-lijie", "downloads": [ { "name": "Windows 构建包", - "description": "项目打包文件(可选)", - "url": "http://106.12.111.150:8000/f/5eb1877a7212488ca0aa/?dl=1", + "description": "项目 李诫传 打包文件", + "url": "http://106.12.111.150:8000/f/c6e397439b174fe39106/?dl=1", "repo_id": "", "path": "", "type": "build", @@ -17,9 +17,17 @@ ], "shares": [ { - "name": "简历 PDF", - "description": "独立公开资源示例,可不绑定项目。", - "url": "", + "name": "Unity 游戏客户端开发简历 PDF", + "description": "求职 Unity 游戏客户端开发岗位的简历", + "url": "http://106.12.111.150:8000/f/937ec9f34ec94d528a52/?dl=1", + "repo_id": "", + "path": "", + "type": "document" + }, + { + "name": "游戏构建开发简历 PDF", + "description": "求职游戏构建开发岗位的简历", + "url": "http://106.12.111.150:8000/f/04deda4586a742a6b5a7/?dl=1", "repo_id": "", "path": "", "type": "document" diff --git a/src/content/shares/index.json b/src/content/shares/index.json index 2095b1f..4c7e386 100644 --- a/src/content/shares/index.json +++ b/src/content/shares/index.json @@ -1,14 +1,8 @@ [ { - "name": "个人主页需求文档", + "name": "配置样例结构", "description": "站点范围、页面结构、数据模型与部署思路的初稿。", "url": "#", - "time": "2026-05-03" - }, - { - "name": "首页设计说明", - "description": "工程编辑部风格的首页设计约束与组件边界。", - "url": "#", - "time": "2026-05-03" + "time": "2026-05-01" } ] diff --git a/src/pages/index.astro b/src/pages/index.astro index 0a9cfa8..1764d41 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -44,7 +44,7 @@ const featuredProjectsUpdatedAt = getLatestDate( 106.12.111.150/logs 这类 不带 :2000 - 的地址并出现 502,请手动把地址改成 + 的地址并出现 404,请手动把地址改成 106.12.111.150:2000/对应路径 即可正常访问其他视图。这个问题是当前 Nginx 反代导致的临时现象,等域名备案完成后会恢复正常。