Module Update
Some checks failed
CI / build-and-test (push) Failing after 1m31s
CI / deploy (push) Has been skipped

This commit is contained in:
SpecialX
2025-12-30 14:42:30 +08:00
parent f1797265b2
commit e7c902e8e1
148 changed files with 19317 additions and 113 deletions

View File

@@ -18,6 +18,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
# 1. 增加 Cache 策略,显著加快 npm ci 速度
- name: Cache npm dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
@@ -27,6 +37,18 @@ jobs:
- name: Typecheck
run: npm run typecheck
# 2. 增加 Next.js 构建缓存
- name: Cache Next.js build
uses: actions/cache@v3
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Build
run: npm run build
@@ -35,7 +57,7 @@ jobs:
# echo "======================="
# echo "1. Root directory files:"
# ls -la
#
# echo "======================="
# echo "2. Checking .next directory:"
# if [ -d ".next" ]; then
@@ -58,10 +80,10 @@ jobs:
cp -r .next/static/* .next/standalone/.next/static/
cp Dockerfile .next/standalone/Dockerfile
- name: 🔍 Debug - List Build Files
run: |
echo "======================="
ls -la .next/standalone
# - name: 🔍 Debug - List Build Files
# run: |
# echo "======================="
# ls -la .next/standalone
- name: Upload production build artifact
uses: actions/upload-artifact@v3
@@ -83,8 +105,21 @@ jobs:
- name: Deploy to Docker
run: |
docker build -t nextjs-app .
# 1. 使用 --no-cache 防止使用旧的构建层,确保部署的是最新代码
# 2. 使用 --pull 确保基础镜像是最新的
docker build --no-cache --pull -t nextjs-app .
# 3. 优雅停止:先尝试 stop如果失败则无需处理 (|| true)
docker stop nextjs-app || true
docker rm nextjs-app || true
docker run -d -p 8015:3000 --restart unless-stopped --name nextjs-app nextjs-app
# 4. 运行容器:
# --init: 解决 Node.js PID 1 僵尸进程问题
# --restart unless-stopped: 自动重启策略
docker run -d \
--init \
-p 8015:3000 \
--restart unless-stopped \
--name nextjs-app \
nextjs-app