mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-11 14:56:57 +08:00
Docs: Add Docker one-click deployment support for all languages
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>
This commit is contained in:
59
Dockerfile
Normal file
59
Dockerfile
Normal file
@@ -0,0 +1,59 @@
|
||||
# 构建阶段
|
||||
FROM golang:1.21-alpine AS builder
|
||||
|
||||
# 安装必要的构建工具
|
||||
RUN apk add --no-cache git gcc musl-dev
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制 go mod 文件
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# 下载依赖
|
||||
RUN go mod download
|
||||
|
||||
# 复制源代码
|
||||
COPY . .
|
||||
|
||||
# 构建应用
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o nofx .
|
||||
|
||||
# 运行阶段
|
||||
FROM alpine:latest
|
||||
|
||||
# 安装 ca-certificates(HTTPS 请求需要)
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
# 设置时区为上海
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
# 创建非 root 用户
|
||||
RUN addgroup -g 1000 nofx && \
|
||||
adduser -D -u 1000 -G nofx nofx
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 从构建阶段复制二进制文件
|
||||
COPY --from=builder /app/nofx .
|
||||
|
||||
# 复制配置文件示例
|
||||
COPY config.json.example ./config.json.example
|
||||
|
||||
# 创建必要的目录
|
||||
RUN mkdir -p decision_logs coin_pool_cache && \
|
||||
chown -R nofx:nofx /app
|
||||
|
||||
# 切换到非 root 用户
|
||||
USER nofx
|
||||
|
||||
# 暴露 API 端口
|
||||
EXPOSE 8080
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
||||
|
||||
# 启动应用
|
||||
CMD ["./nofx"]
|
||||
Reference in New Issue
Block a user