Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions kazumi-web/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Dependencies
node_modules
.pnp
.pnp.js

# Testing
coverage

# Next.js
.next
out

# Production
build

# Misc
.DS_Store
*.pem

# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Local env files
.env*.local
.env

# Vercel
.vercel

# TypeScript
*.tsbuildinfo
next-env.d.ts

# IDE
.idea
.vscode
*.swp
*.swo

# Git
.git
.gitignore

# Docker
Dockerfile*
docker-compose*
.dockerignore

# Documentation
README.md
DEPLOY.md

# Screenshots
screenshot-*.png

# Test files
__tests__
*.test.ts
*.test.tsx
*.spec.ts
*.spec.tsx
9 changes: 9 additions & 0 deletions kazumi-web/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["next/core-web-vitals", "next/typescript", "prettier"],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"react/no-unescaped-entities": "off",
"react-hooks/exhaustive-deps": "warn"
}
}
53 changes: 53 additions & 0 deletions kazumi-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage
/playwright-report
/test-results

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# PWA
/public/sw.js
/public/workbox-*.js
/public/worker-*.js
/public/sw.js.map
/public/workbox-*.js.map
/public/worker-*.js.map

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
9 changes: 9 additions & 0 deletions kazumi-web/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 100,
"arrowParens": "always",
"endOfLine": "lf"
}
135 changes: 135 additions & 0 deletions kazumi-web/DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# 部署指南

## Docker 部署

### 方式 1: 使用 Docker Compose (推荐本地测试)

```bash
# 进入项目目录
cd ios-liquid-glass-video-player

# 构建并启动
docker-compose up -d

# 查看日志
docker-compose logs -f

# 停止服务
docker-compose down
```

### 方式 2: 直接使用 Docker

```bash
# 构建镜像
docker build -t anime-player .

# 运行容器
docker run -d \
--name anime-player \
-p 3000:3000 \
--shm-size=2g \
--security-opt seccomp=unconfined \
anime-player

# 查看日志
docker logs -f anime-player
```

### 方式 3: 部署到 Zeabur

1. 在 Zeabur 创建新项目
2. 选择 "Deploy from GitHub" 或 "Deploy from Docker Image"
3. 如果使用 GitHub:
- 连接你的 GitHub 仓库
- Zeabur 会自动检测 Dockerfile 并构建
4. 如果使用 Docker Image:
- 先推送镜像到 Docker Hub:
```bash
docker build -t your-username/anime-player .
docker push your-username/anime-player
```
- 在 Zeabur 中输入镜像名称

#### Zeabur 环境变量配置

在 Zeabur 控制台设置以下环境变量:

| 变量名 | 值 | 说明 |
|--------|-----|------|
| `NODE_ENV` | `production` | 生产环境 |
| `PUPPETEER_EXECUTABLE_PATH` | `/usr/bin/chromium` | Chromium 路径 |

#### Zeabur 资源配置建议

- **内存**: 至少 1GB,推荐 2GB (Chromium 需要)
- **CPU**: 至少 0.5 核,推荐 1 核
- **共享内存**: 如果可配置,设置为 2GB

---

## 常见问题

### Q: Puppeteer 启动失败

确保容器有足够的共享内存:
```bash
docker run --shm-size=2g ...
```

或在 docker-compose.yml 中设置:
```yaml
shm_size: '2gb'
```

### Q: 视频解析超时

视频解析需要 10-20 秒,确保:
1. 服务器有足够的 CPU 和内存
2. 网络连接稳定
3. 没有防火墙阻止出站连接

### Q: 字体显示问题

Docker 镜像已包含中文字体 (fonts-noto-cjk),如果仍有问题:
```bash
apt-get install fonts-wqy-zenhei fonts-noto-cjk
```

### Q: 内存不足

Chromium 需要较多内存,建议:
- 最小: 1GB
- 推荐: 2GB
- 如果同时处理多个请求: 4GB

---

## 端口说明

| 端口 | 用途 |
|------|------|
| 3000 | HTTP 服务 |

---

## API 端点

| 端点 | 说明 |
|------|------|
| `/` | 首页 |
| `/api/bangumi/*` | Bangumi API 代理 |
| `/api/dandanplay/*` | 弹弹Play API 代理 |
| `/api/plugins/*` | 插件 API |
| `/api/proxy/video` | 视频代理 |
| `/api/proxy/image` | 图片代理 |

---

## 健康检查

```bash
curl http://localhost:3000/api/bangumi/calendar
```

返回 200 表示服务正常。
106 changes: 106 additions & 0 deletions kazumi-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# ============================================
# 番剧播放器 Docker 镜像
# 支持 Puppeteer + Chromium 用于视频解析
# ============================================

# 阶段 1: 依赖安装
FROM node:20-slim AS deps

WORKDIR /app

# 复制 package 文件
COPY package.json package-lock.json* ./

# 安装依赖 (包括 devDependencies 用于构建)
RUN npm ci

# ============================================
# 阶段 2: 构建
FROM node:20-slim AS builder

WORKDIR /app

# 复制依赖
COPY --from=deps /app/node_modules ./node_modules

# 复制源代码
COPY . .

# 设置环境变量
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# 跳过 Puppeteer 下载 Chromium (我们在 runner 阶段安装)
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

# 构建应用
RUN npm run build

# ============================================
# 阶段 3: 生产运行
FROM node:20-slim AS runner

WORKDIR /app

# 设置环境变量 (在安装包之前)
ENV DEBIAN_FRONTEND=noninteractive
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV CHROMIUM_PATH=/usr/bin/chromium

# 安装 Chromium 和必要的依赖
RUN apt-get update && apt-get install -y \
chromium \
fonts-ipafont-gothic \
fonts-wqy-zenhei \
fonts-thai-tlwg \
fonts-kacst \
fonts-freefont-ttf \
fonts-noto-cjk \
libxss1 \
libxtst6 \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libcairo2 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

# 创建非 root 用户
RUN groupadd --gid 1001 nodejs && \
useradd --uid 1001 --gid nodejs --shell /bin/bash --create-home nextjs

# 设置运行时环境变量
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

# 复制构建产物
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# 切换到非 root 用户
USER nextjs

# 暴露端口
EXPOSE 3000

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD node -e "const http = require('http'); http.get('http://localhost:3000/api/bangumi/calendar', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"

# 启动命令
CMD ["node", "server.js"]
Loading
Loading