mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
a7d0ca8835
Complete Docker deployment solution with beginner-friendly documentation: **New Docker Files:** - `Dockerfile` - Multi-stage Go backend build with health checks - `web/Dockerfile` - Frontend build with Nginx and API proxy - `docker-compose.yml` - Full orchestration with service dependencies - `.dockerignore` & `web/.dockerignore` - Build optimization - `start.sh` - Convenient management script (start/stop/logs/status) **Comprehensive Documentation:** - `DOCKER_DEPLOY.md` (中文) - Complete Chinese deployment guide - `DOCKER_DEPLOY.en.md` (English) - Complete English deployment guide - Prerequisites & Docker installation (macOS/Windows/Linux) - 3-step quick start (config → start → access) - Service management commands - Advanced configuration (ports, resources, env vars) - Data persistence & backups - Comprehensive troubleshooting - Security recommendations - Production deployment (Nginx, HTTPS, Docker Swarm) - Monitoring & logging setup **README Updates (All 4 Languages):** - README.md (English) - README.zh-CN.md (中文) - README.uk.md (Українська) - README.ru.md (Русский) Added prominent "Option A: Docker One-Click Deployment" section at the beginning of Quick Start in all languages. Clearly marked as EASIEST method for beginners. Shows 3 simple steps with command examples and links to detailed DOCKER_DEPLOY docs. **Key Features:** - One-command deployment: `./start.sh start --build` - Auto-handles all dependencies (Go, Node.js, TA-Lib) - Health checks for both services - Data persistence (logs, cache, config) - Log rotation (10MB × 3 files) - Easy service management - Beginner-friendly for complete newcomers **User Benefits:** - No need to install Go, Node.js, or TA-Lib manually - Works on macOS, Windows, Linux - Perfect for non-developers - Production-ready with best practices This makes NOFX truly accessible to beginners as requested: "真就让小白都能一键开始" Co-Authored-By: tinkle-community <tinklefund@gmail.com>
73 lines
1.7 KiB
Docker
73 lines
1.7 KiB
Docker
# 构建阶段
|
|
FROM node:20-alpine AS builder
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# 复制 package 文件
|
|
COPY package*.json ./
|
|
|
|
# 安装依赖
|
|
RUN npm ci --only=production=false
|
|
|
|
# 复制源代码
|
|
COPY . .
|
|
|
|
# 构建应用
|
|
RUN npm run build
|
|
|
|
# 运行阶段
|
|
FROM nginx:alpine
|
|
|
|
# 复制自定义 nginx 配置
|
|
COPY <<EOF /etc/nginx/conf.d/default.conf
|
|
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# 启用 gzip 压缩
|
|
gzip on;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
gzip_min_length 1000;
|
|
|
|
# SPA 路由支持
|
|
location / {
|
|
try_files \$uri \$uri/ /index.html;
|
|
}
|
|
|
|
# API 代理到后端
|
|
location /api/ {
|
|
proxy_pass http://backend:8080/api/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host \$host;
|
|
proxy_cache_bypass \$http_upgrade;
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
|
}
|
|
|
|
# 健康检查端点
|
|
location /health {
|
|
proxy_pass http://backend:8080/health;
|
|
access_log off;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# 从构建阶段复制构建产物
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost/health || exit 1
|
|
|
|
# 启动 nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|