Skip to content

Commit 4f83489

Browse files
author
mcgrady.sun
committed
feat: MVP 0.1.0
0 parents  commit 4f83489

File tree

372 files changed

+57079
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+57079
-0
lines changed

.docker/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# ---- 构建阶段 ----
2+
FROM node:20-bullseye-slim AS builder
3+
4+
WORKDIR /app
5+
COPY . .
6+
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate && pnpm install --frozen-lockfile --prod=false \
7+
&& pnpm run build:all
8+
9+
10+
FROM node:20-bullseye-slim AS app
11+
12+
# 显式声明通过 build-args 传递的变量
13+
ARG VERSION
14+
ARG GIT_SHA
15+
ARG GITHUB_REPOSITORY
16+
17+
LABEL org.opencontainers.image.version=$VERSION \
18+
org.opencontainers.image.revision=$GIT_SHA \
19+
org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY:-unknown}"
20+
21+
WORKDIR /app
22+
ENV NODE_ENV=production
23+
24+
# Install nginx
25+
# 安装 puppeteer 运行所需的系统依赖
26+
RUN apt-get update && apt-get install -y \
27+
curl \
28+
vim \
29+
nginx \
30+
chromium \
31+
fonts-liberation \
32+
fonts-noto-cjk \
33+
fonts-noto-color-emoji \
34+
fonts-wqy-zenhei \
35+
fonts-wqy-microhei \
36+
fontconfig \
37+
libasound2 \
38+
libatk-bridge2.0-0 \
39+
libatk1.0-0 \
40+
libcups2 \
41+
libdbus-1-3 \
42+
libdrm2 \
43+
libgbm1 \
44+
libnspr4 \
45+
libnss3 \
46+
libxcomposite1 \
47+
libxdamage1 \
48+
libxrandr2 \
49+
xdg-utils \
50+
--no-install-recommends \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
# 只复制运行所需产物
54+
COPY --from=builder /app/ ./
55+
RUN find ./ -type f -name '*.ts' -delete
56+
COPY .docker/nginx.conf /etc/nginx/nginx.conf
57+
COPY .docker/entrypoint.sh /entrypoint.sh
58+
59+
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
60+
RUN chmod +x /entrypoint.sh
61+
62+
EXPOSE 80
63+
CMD ["/entrypoint.sh"]

.docker/entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Env
5+
export NODE_ENV=production
6+
7+
# Start server via pnpm workspace
8+
pnpm -w -F server start &
9+
10+
# Start nginx in foreground
11+
nginx -g 'daemon off;'

.docker/nginx.conf

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
user root;
2+
worker_processes auto;
3+
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
'$status $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent" "$http_x_forwarded_for"';
18+
19+
access_log /var/log/nginx/access.log main;
20+
21+
sendfile on;
22+
#tcp_nopush on;
23+
24+
keepalive_timeout 65;
25+
26+
gzip on;
27+
gzip_min_length 1k;
28+
gzip_comp_level 5;
29+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
30+
gzip_proxied any;
31+
32+
client_max_body_size 20m;
33+
34+
server {
35+
listen 80;
36+
server_name _;
37+
38+
# static web
39+
root /app/apps/web/dist;
40+
index index.html;
41+
42+
location /api/ {
43+
proxy_pass http://127.0.0.1:7002;
44+
proxy_http_version 1.1;
45+
proxy_set_header Upgrade $http_upgrade;
46+
proxy_set_header Connection "upgrade";
47+
proxy_set_header Host $host;
48+
proxy_set_header X-Real-IP $remote_addr;
49+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50+
proxy_set_header X-Forwarded-Proto $scheme;
51+
proxy_buffering off;
52+
proxy_read_timeout 300;
53+
}
54+
55+
location / {
56+
try_files $uri $uri/ /index.html;
57+
}
58+
}
59+
}

.dockerignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Exclude VCS & editors
2+
.git
3+
.gitignore
4+
.vscode
5+
.idea
6+
7+
# Node & logs
8+
#**/node_modules
9+
**/.turbo
10+
**/.next
11+
#**/dist
12+
**/coverage
13+
**/.DS_Store
14+
**/npm-debug.log*
15+
**/yarn-error.log*
16+
**/pnpm-debug.log*
17+
18+
# Tests, docs, examples
19+
**/__tests__
20+
**/*.spec.*
21+
**/*.test.*
22+
**/docs
23+
**/test
24+
25+
# Local env & configs
26+
.env*
27+
!.env.example
28+
**/*.local.*
29+
**/*.dev.*
30+
31+
# Docker build context: keep only what we need for build & runtime
32+
# Allow lists to include sources, package manifests, lockfile, configs
33+
# Note: dockerignore doesn't have true allowlists; instead we ignore broadly and then re-include below using !
34+
35+
# Re-include package manifests and lock/workspace files
36+
!package.json
37+
!pnpm-lock.yaml
38+
!pnpm-workspace.yaml
39+
!turbo.json
40+
!tsconfig.json
41+
42+
# Re-include app/package manifests and sources
43+
!apps/**/package.json
44+
!apps/**/src/**
45+
!apps/**/public/**
46+
!apps/**/index.html
47+
!apps/**/vite.config.*
48+
!apps/**/tsconfig.*
49+
50+
# Re-include packages manifests and sources
51+
!packages/**/package.json
52+
!packages/**/src/**
53+
!packages/**/tsconfig.*
54+
55+
# Keep shared workflow configs used at build time
56+
!workflow/**
57+
58+
# Keep .docker assets
59+
!.docker/**
60+
61+
# Keep scripts used by Docker build
62+
!scripts/**

.env

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
# ==========================
3+
# 必填项(建议优先填写)
4+
# ==========================
5+
WEB_URL=http://localhost:3020 # 应用主机地址,部署后需改为实际域名
6+
7+
# 数据库连接(MySQL)
8+
DATABASE_URL=mysql://lumina:your_db_password@lumina-mysql:3306/lumina # 必填,密码请替换为实际值
9+
10+
# 管理员初始化
11+
ADMIN_EMAIL=admin@lumina.local # 必填,管理员邮箱
12+
ADMIN_USERNAME=admin # 必填,管理员用户名
13+
ADMIN_PASSWORD=admin # 必填,请替换为实际密码
14+
15+
# ==========================
16+
# 选填项(可根据实际需求填写)
17+
# ==========================
18+
19+
# 邮件发送配置(如需邮件通知/订阅功能)
20+
MAIL_HOST=smtp.example.com # 邮件服务器地址
21+
MAIL_PORT=465 # 邮件服务器端口
22+
MAIL_SECURE=true # 是否启用 SSL
23+
MAIL_USER=your_mail_user # 邮箱账号
24+
MAIL_PASS=your_mail_password # 邮箱密码
25+
MAIL_FROM=your_mail_from # 发件人邮箱
26+
27+
# 存储渠道选择(r2、s3、oss,三选一)
28+
STORAGE_TYPE=r2
29+
30+
# R2 配置(如用 Cloudflare R2)
31+
R2_ACCESS_KEY_ID=your_r2_access_key_id
32+
R2_SECRET_ACCESS_KEY=your_r2_secret_access_key
33+
R2_BUCKET=your_r2_bucket
34+
R2_ENDPOINT=https://your_r2_endpoint
35+
R2_PUBLIC_URL=https://your_r2_public_url
36+
37+
# S3 配置(如用 AWS S3)
38+
S3_ACCESS_KEY_ID=your_s3_access_key_id
39+
S3_SECRET_ACCESS_KEY=your_s3_secret_access_key
40+
S3_BUCKET=your_s3_bucket
41+
S3_REGION=us-east-1
42+
S3_ENDPOINT=https://s3.amazonaws.com
43+
S3_PUBLIC_URL=https://your_s3_bucket.s3.amazonaws.com
44+
45+
# OSS 配置(如用阿里云 OSS)
46+
OSS_ACCESS_KEY_ID=your_oss_access_key_id
47+
OSS_ACCESS_KEY_SECRET=your_oss_access_key_secret
48+
OSS_BUCKET=your_oss_bucket
49+
OSS_REGION=oss-cn-hangzhou
50+
OSS_PUBLIC_URL=https://your_oss_bucket.oss-cn-hangzhou.aliyuncs.com
51+
52+
# Redis 配置(如需限流/订阅)
53+
REDIS_HOST=lumina-redis
54+
REDIS_PORT=6379
55+
REDIS_PASSWORD=
56+
REDIS_DB=0
57+
58+
# MQ 配置(如需订阅调度)
59+
MQ_HOST=lumina-rabbitmq
60+
MQ_PORT=5672
61+
MQ_USER=admin
62+
MQ_PASS=admin
63+
MQ_VHOST=
64+
65+
# 预览/分享功能密钥
66+
PREVIEW_TOKEN_SECRET=htk7GCnPLwZgkgFGZ43QSOFTm8sFa6yd
67+
68+
# Root 超级用户 ID 列表(逗号分隔)
69+
LUMINA_ROOT_USER_IDS=
70+
71+
# 存储开关(如需禁用存储功能)
72+
LUMINA_FORCE_NO_STORAGE=

.env.test

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# App ports (not used by egg-mock, reserved)
3+
SERVER_PORT=17002
4+
WEB_PORT=15173
5+
6+
# Database (use separate DB)
7+
DATABASE_URL=mysql://lumina:lumina123@127.0.0.1:33306/lumina_test
8+
9+
# Default admin
10+
ADMIN_EMAIL=test-admin@lumina.local
11+
ADMIN_USERNAME=admin
12+
ADMIN_PASSWORD=admin123
13+
14+
# MQ / Redis (tests skip SubscriptionManager by NODE_ENV=test)
15+
MQ_USER=admin
16+
MQ_PASS=admin
17+
MQ_HOST=127.0.0.1
18+
MQ_PORT=35672
19+
MQ_VHOST=
20+
21+
REDIS_HOST=127.0.0.1
22+
REDIS_PORT=36379
23+
REDIS_PASSWORD=
24+
REDIS_DB=15
25+
26+
# Preview token
27+
PREVIEW_TOKEN_SECRET=preview_test_secret
28+
29+
# Root user ids (avoid treating user #1 as root in tests)
30+
LUMINA_ROOT_USER_IDS=2
31+
32+
# Web URL (for absolute links if needed)
33+
WEB_URL=http://localhost:${WEB_PORT}

.eslintignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**/node_modules/**
2+
**/dist/**
3+
**/.turbo/**
4+
**/coverage/**
5+
.devcontainer/**
6+
.vscode/**
7+
8+
# dev runtime folders
9+
/dev/**/data/**
10+
/dev/**/logs/**
11+
/dev/**/backups/**
12+
13+
mysql-backup.sql

.eslintrc.cjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 根级 ESLint 配置
3+
* - 默认使用自定义通用配置(workflow/eslint-config-custom)
4+
* - 对 React/TSX 文件应用 React 增强配置
5+
*/
6+
module.exports = {
7+
root: true,
8+
extends: [
9+
"./workflow/eslint-config-custom"
10+
],
11+
overrides: [
12+
],
13+
ignorePatterns: [
14+
"**/node_modules/**",
15+
"**/dist/**",
16+
"**/.turbo/**",
17+
"**/coverage/**",
18+
"dev/**/data/**",
19+
"dev/**/logs/**",
20+
"mysql-backup.sql"
21+
]
22+
}

0 commit comments

Comments
 (0)