feat(docker): 添加完整的 Docker 构建支持

- 重构 Dockerfile 支持本地完整源码构建流程
- 添加 CI 专用的 Dockerfile.ci 使用预构建产物
- 创建 .dockerignore 和 .dockerignore.ci 文件优化构建上下文
- 添加 build-docker.sh 和 build-docker.bat 本地构建脚本
- 更新 GitHub Actions 工作流支持 Node.js 环境和 pnpm 依赖管理
- 添加 DOCKER.md 详细说明文档
- 优化 nginx 配置和端口暴露设置
This commit is contained in:
coolxitech
2026-01-08 17:13:46 +08:00
parent 21cf5762d2
commit d9c708e0ca
8 changed files with 279 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
name: Docker 多架构构建并发布
name: 构建并发布 Docker 镜像
on:
push:
@@ -19,6 +19,41 @@ jobs:
with:
fetch-depth: 0
# 设置 Node.js 环境
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# 设置 pnpm
- name: 设置 pnpm
uses: pnpm/action-setup@v4
with:
version: latest
# 缓存 pnpm 依赖
- name: 缓存 pnpm 依赖
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
# 安装依赖
- name: 安装依赖
run: pnpm install
# 构建项目
- name: 构建项目
run: pnpm run build
# 准备 CI 构建环境
- name: 准备 CI 构建环境
run: |
# 使用 CI 专用的 dockerignore
cp .dockerignore.ci .dockerignore
# QEMU 用于支持多架构构建(必须)
- name: 设置 QEMU
uses: docker/setup-qemu-action@v3
@@ -43,11 +78,12 @@ jobs:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 真正一键构建 + 推送多架构镜像amd64 + arm64
# 构建并推送多架构镜像(使用构建产物
- name: 构建并推送多架构镜像
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.ci
platforms: linux/amd64,linux/arm64
push: true
tags: |
@@ -58,4 +94,3 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=OGame Vue Ts
no-cache: true