mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-06-06 05:51:19 +08:00
feat: add one-click install and simplify README
- Add docker-compose.prod.yml with env_file support - Add install.sh with auto-generated encryption keys - Remove API endpoints and recommendations from README - Add multi-language links to README
This commit is contained in:
76
README.md
76
README.md
@@ -11,7 +11,7 @@
|
||||
| Code · Bug Fixes · Issues → Airdrop |
|
||||
| [Learn More](#contributor-airdrop-program) |
|
||||
|
||||
**Languages:** [English](README.md) | [中文](docs/i18n/zh-CN/README.md)
|
||||
**Languages:** [English](README.md) | [中文](docs/i18n/zh-CN/README.md) | [日本語](docs/i18n/ja/README.md) | [한국어](docs/i18n/ko/README.md) | [Русский](docs/i18n/ru/README.md) | [Українська](docs/i18n/uk/README.md) | [Tiếng Việt](docs/i18n/vi/README.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -95,29 +95,34 @@ Join our Telegram developer community: **[NOFX Developer Community](https://t.me
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Option 1: Docker Deployment (Recommended)
|
||||
### One-Click Install (Recommended)
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/NoFxAiOS/nofx/main/install.sh | bash
|
||||
```
|
||||
|
||||
That's it! Open **http://localhost:3000** in your browser.
|
||||
|
||||
### Docker Compose (Manual)
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/NoFxAiOS/nofx.git
|
||||
cd nofx
|
||||
|
||||
# Start with Docker
|
||||
chmod +x ./start.sh
|
||||
./start.sh start --build
|
||||
# Download and start
|
||||
curl -O https://raw.githubusercontent.com/NoFxAiOS/nofx/main/docker-compose.prod.yml
|
||||
docker compose -f docker-compose.prod.yml up -d
|
||||
```
|
||||
|
||||
Access Web Interface: **http://localhost:3000**
|
||||
|
||||
```bash
|
||||
# Management commands
|
||||
./start.sh logs # View logs
|
||||
./start.sh status # Check status
|
||||
./start.sh stop # Stop services
|
||||
./start.sh restart # Restart services
|
||||
docker compose -f docker-compose.prod.yml logs -f # View logs
|
||||
docker compose -f docker-compose.prod.yml restart # Restart
|
||||
docker compose -f docker-compose.prod.yml down # Stop
|
||||
docker compose -f docker-compose.prod.yml pull && docker compose -f docker-compose.prod.yml up -d # Update
|
||||
```
|
||||
|
||||
### Option 2: Manual Installation
|
||||
### Manual Installation (For Developers)
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
@@ -197,49 +202,6 @@ All configuration is done through the web interface - no JSON file editing requi
|
||||
|
||||
---
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Trader Management
|
||||
```
|
||||
GET /api/traders # List all traders
|
||||
POST /api/traders # Create new trader
|
||||
DELETE /api/traders/:id # Delete trader
|
||||
POST /api/traders/:id/start # Start trader
|
||||
POST /api/traders/:id/stop # Stop trader
|
||||
```
|
||||
|
||||
### Strategy Management
|
||||
```
|
||||
GET /api/strategies # List all strategies
|
||||
POST /api/strategies # Create new strategy
|
||||
PUT /api/strategies/:id # Update strategy
|
||||
DELETE /api/strategies/:id # Delete strategy
|
||||
```
|
||||
|
||||
### Trading Data
|
||||
```
|
||||
GET /api/status?trader_id=xxx # System status
|
||||
GET /api/account?trader_id=xxx # Account info
|
||||
GET /api/positions?trader_id=xxx # Position list
|
||||
GET /api/decisions/latest?trader_id=xxx # Latest decisions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Risk Warnings
|
||||
|
||||
1. **Cryptocurrency markets are extremely volatile** - AI decisions don't guarantee profit
|
||||
2. **Futures trading uses leverage** - losses may exceed principal
|
||||
3. **Extreme market conditions** may lead to liquidation risk
|
||||
|
||||
**Recommendations:**
|
||||
- Use only funds you can afford to lose
|
||||
- Start with small amounts (100-500 USDT)
|
||||
- Regularly monitor system operation
|
||||
- Don't run unsupervised for long periods
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### TA-Lib not found
|
||||
|
||||
62
docker-compose.prod.yml
Normal file
62
docker-compose.prod.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
# NOFX Production Deployment
|
||||
# 用户部署专用 - 使用官方预构建镜像
|
||||
#
|
||||
# 一键部署命令:
|
||||
# curl -fsSL https://raw.githubusercontent.com/NoFxAiOS/nofx/main/install.sh | bash
|
||||
#
|
||||
# 或手动部署:
|
||||
# curl -O https://raw.githubusercontent.com/NoFxAiOS/nofx/main/docker-compose.prod.yml
|
||||
# docker compose -f docker-compose.prod.yml up -d
|
||||
|
||||
services:
|
||||
nofx:
|
||||
image: ghcr.io/nofxaios/nofx/nofx-backend:latest
|
||||
container_name: nofx-trading
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 30s
|
||||
ports:
|
||||
- "${NOFX_BACKEND_PORT:-8080}:8080"
|
||||
volumes:
|
||||
- nofx-data:/app/data
|
||||
- nofx-logs:/app/decision_logs
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- TZ=${TZ:-Asia/Shanghai}
|
||||
- AI_MAX_TOKENS=4000
|
||||
networks:
|
||||
- nofx-network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
nofx-frontend:
|
||||
image: ghcr.io/nofxaios/nofx/nofx-frontend:latest
|
||||
container_name: nofx-frontend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${NOFX_FRONTEND_PORT:-3000}:80"
|
||||
networks:
|
||||
- nofx-network
|
||||
depends_on:
|
||||
- nofx
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
|
||||
networks:
|
||||
nofx-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
nofx-data:
|
||||
name: nofx-data
|
||||
nofx-logs:
|
||||
name: nofx-logs
|
||||
@@ -11,7 +11,7 @@
|
||||
| 代码 · Bug修复 · Issue → 空投奖励 |
|
||||
| [了解更多](#贡献者空投计划) |
|
||||
|
||||
**语言:** [English](../../../README.md) | [中文](README.md)
|
||||
**语言:** [English](../../../README.md) | [中文](README.md) | [日本語](../ja/README.md) | [한국어](../ko/README.md) | [Русский](../ru/README.md) | [Українська](../uk/README.md) | [Tiếng Việt](../vi/README.md)
|
||||
|
||||
---
|
||||
|
||||
@@ -95,29 +95,34 @@
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 方式一: Docker 部署 (推荐)
|
||||
### 一键安装 (推荐)
|
||||
|
||||
**Linux / macOS:**
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/NoFxAiOS/nofx/main/install.sh | bash
|
||||
```
|
||||
|
||||
完成!打开浏览器访问 **http://localhost:3000**
|
||||
|
||||
### Docker Compose (手动)
|
||||
|
||||
```bash
|
||||
# 克隆仓库
|
||||
git clone https://github.com/NoFxAiOS/nofx.git
|
||||
cd nofx
|
||||
|
||||
# 使用 Docker 启动
|
||||
chmod +x ./start.sh
|
||||
./start.sh start --build
|
||||
# 下载并启动
|
||||
curl -O https://raw.githubusercontent.com/NoFxAiOS/nofx/main/docker-compose.prod.yml
|
||||
docker compose -f docker-compose.prod.yml up -d
|
||||
```
|
||||
|
||||
访问 Web 界面: **http://localhost:3000**
|
||||
|
||||
```bash
|
||||
# 管理命令
|
||||
./start.sh logs # 查看日志
|
||||
./start.sh status # 检查状态
|
||||
./start.sh stop # 停止服务
|
||||
./start.sh restart # 重启服务
|
||||
docker compose -f docker-compose.prod.yml logs -f # 查看日志
|
||||
docker compose -f docker-compose.prod.yml restart # 重启
|
||||
docker compose -f docker-compose.prod.yml down # 停止
|
||||
docker compose -f docker-compose.prod.yml pull && docker compose -f docker-compose.prod.yml up -d # 更新
|
||||
```
|
||||
|
||||
### 方式二: 手动安装
|
||||
### 手动安装 (开发者)
|
||||
|
||||
#### 前置条件
|
||||
|
||||
@@ -197,49 +202,6 @@ npm run dev
|
||||
|
||||
---
|
||||
|
||||
## API 接口
|
||||
|
||||
### 交易员管理
|
||||
```
|
||||
GET /api/traders # 列出所有交易员
|
||||
POST /api/traders # 创建新交易员
|
||||
DELETE /api/traders/:id # 删除交易员
|
||||
POST /api/traders/:id/start # 启动交易员
|
||||
POST /api/traders/:id/stop # 停止交易员
|
||||
```
|
||||
|
||||
### 策略管理
|
||||
```
|
||||
GET /api/strategies # 列出所有策略
|
||||
POST /api/strategies # 创建新策略
|
||||
PUT /api/strategies/:id # 更新策略
|
||||
DELETE /api/strategies/:id # 删除策略
|
||||
```
|
||||
|
||||
### 交易数据
|
||||
```
|
||||
GET /api/status?trader_id=xxx # 系统状态
|
||||
GET /api/account?trader_id=xxx # 账户信息
|
||||
GET /api/positions?trader_id=xxx # 持仓列表
|
||||
GET /api/decisions/latest?trader_id=xxx # 最新决策
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 风险提示
|
||||
|
||||
1. **加密货币市场波动剧烈** - AI 决策不保证盈利
|
||||
2. **期货交易使用杠杆** - 亏损可能超过本金
|
||||
3. **极端行情** 可能导致爆仓风险
|
||||
|
||||
**建议:**
|
||||
- 仅使用可承受损失的资金
|
||||
- 从小额开始 (100-500 USDT)
|
||||
- 定期监控系统运行状态
|
||||
- 不要长时间无人值守运行
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
### TA-Lib 未找到
|
||||
|
||||
202
install.sh
Normal file
202
install.sh
Normal file
@@ -0,0 +1,202 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# NOFX One-Click Installation Script
|
||||
# https://github.com/NoFxAiOS/nofx
|
||||
#
|
||||
# Usage:
|
||||
# curl -fsSL https://raw.githubusercontent.com/NoFxAiOS/nofx/main/install.sh | bash
|
||||
#
|
||||
# Or with custom directory:
|
||||
# curl -fsSL https://raw.githubusercontent.com/NoFxAiOS/nofx/main/install.sh | bash -s -- /opt/nofx
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Default installation directory
|
||||
INSTALL_DIR="${1:-$HOME/nofx}"
|
||||
COMPOSE_FILE="docker-compose.prod.yml"
|
||||
GITHUB_RAW="https://raw.githubusercontent.com/NoFxAiOS/nofx/main"
|
||||
|
||||
echo -e "${BLUE}"
|
||||
echo "╔════════════════════════════════════════════════════════════╗"
|
||||
echo "║ NOFX AI Trading OS ║"
|
||||
echo "║ One-Click Installation ║"
|
||||
echo "╚════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
# Check Docker
|
||||
check_docker() {
|
||||
echo -e "${YELLOW}Checking Docker...${NC}"
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo -e "${RED}Error: Docker is not installed.${NC}"
|
||||
echo "Please install Docker first: https://docs.docker.com/get-docker/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker info &> /dev/null; then
|
||||
echo -e "${RED}Error: Docker daemon is not running.${NC}"
|
||||
echo "Please start Docker and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Docker Compose
|
||||
if docker compose version &> /dev/null; then
|
||||
COMPOSE_CMD="docker compose"
|
||||
elif command -v docker-compose &> /dev/null; then
|
||||
COMPOSE_CMD="docker-compose"
|
||||
else
|
||||
echo -e "${RED}Error: Docker Compose is not available.${NC}"
|
||||
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Docker is ready${NC}"
|
||||
}
|
||||
|
||||
# Create installation directory
|
||||
setup_directory() {
|
||||
echo -e "${YELLOW}Setting up installation directory: ${INSTALL_DIR}${NC}"
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
cd "$INSTALL_DIR"
|
||||
echo -e "${GREEN}✓ Directory ready${NC}"
|
||||
}
|
||||
|
||||
# Download compose file
|
||||
download_files() {
|
||||
echo -e "${YELLOW}Downloading configuration files...${NC}"
|
||||
|
||||
curl -fsSL "$GITHUB_RAW/$COMPOSE_FILE" -o docker-compose.yml
|
||||
|
||||
echo -e "${GREEN}✓ Files downloaded${NC}"
|
||||
}
|
||||
|
||||
# Generate encryption keys and create .env file
|
||||
generate_env() {
|
||||
echo -e "${YELLOW}Generating encryption keys...${NC}"
|
||||
|
||||
# Skip if .env already exists
|
||||
if [ -f ".env" ]; then
|
||||
echo -e "${GREEN}✓ .env file already exists, skipping key generation${NC}"
|
||||
return
|
||||
fi
|
||||
|
||||
# Generate JWT secret (32 bytes, base64)
|
||||
JWT_SECRET=$(openssl rand -base64 32)
|
||||
|
||||
# Generate AES data encryption key (32 bytes, base64)
|
||||
DATA_ENCRYPTION_KEY=$(openssl rand -base64 32)
|
||||
|
||||
# Generate RSA private key (2048 bits)
|
||||
RSA_PRIVATE_KEY=$(openssl genrsa 2048 2>/dev/null | tr '\n' '\\' | sed 's/\\/\\n/g' | sed 's/\\n$//')
|
||||
|
||||
# Create .env file
|
||||
cat > .env << EOF
|
||||
# NOFX Configuration (Auto-generated)
|
||||
# Generated at: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
# Server ports
|
||||
NOFX_BACKEND_PORT=8080
|
||||
NOFX_FRONTEND_PORT=3000
|
||||
|
||||
# Timezone
|
||||
TZ=Asia/Shanghai
|
||||
|
||||
# JWT signing secret
|
||||
JWT_SECRET=${JWT_SECRET}
|
||||
|
||||
# AES-256 data encryption key (for encrypting API keys in database)
|
||||
DATA_ENCRYPTION_KEY=${DATA_ENCRYPTION_KEY}
|
||||
|
||||
# RSA private key (for client-server encryption)
|
||||
RSA_PRIVATE_KEY=${RSA_PRIVATE_KEY}
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✓ Encryption keys generated${NC}"
|
||||
}
|
||||
|
||||
# Pull images
|
||||
pull_images() {
|
||||
echo -e "${YELLOW}Pulling Docker images (this may take a few minutes)...${NC}"
|
||||
$COMPOSE_CMD pull
|
||||
echo -e "${GREEN}✓ Images pulled${NC}"
|
||||
}
|
||||
|
||||
# Start services
|
||||
start_services() {
|
||||
echo -e "${YELLOW}Starting NOFX services...${NC}"
|
||||
$COMPOSE_CMD up -d
|
||||
echo -e "${GREEN}✓ Services started${NC}"
|
||||
}
|
||||
|
||||
# Wait for services
|
||||
wait_for_services() {
|
||||
echo -e "${YELLOW}Waiting for services to be ready...${NC}"
|
||||
|
||||
local max_attempts=30
|
||||
local attempt=1
|
||||
|
||||
while [ $attempt -le $max_attempts ]; do
|
||||
if curl -s http://localhost:8080/api/health > /dev/null 2>&1; then
|
||||
echo -e "${GREEN}✓ Backend is ready${NC}"
|
||||
break
|
||||
fi
|
||||
echo " Waiting for backend... ($attempt/$max_attempts)"
|
||||
sleep 2
|
||||
((attempt++))
|
||||
done
|
||||
|
||||
if [ $attempt -gt $max_attempts ]; then
|
||||
echo -e "${YELLOW}Backend is still starting, please wait a moment...${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Print success message
|
||||
print_success() {
|
||||
echo ""
|
||||
echo -e "${GREEN}╔════════════════════════════════════════════════════════════╗"
|
||||
echo -e "║ 🎉 Installation Complete! 🎉 ║"
|
||||
echo -e "╚════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo -e " ${BLUE}Web Interface:${NC} http://localhost:3000"
|
||||
echo -e " ${BLUE}API Endpoint:${NC} http://localhost:8080"
|
||||
echo -e " ${BLUE}Install Dir:${NC} $INSTALL_DIR"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Quick Commands:${NC}"
|
||||
echo " cd $INSTALL_DIR"
|
||||
echo " $COMPOSE_CMD logs -f # View logs"
|
||||
echo " $COMPOSE_CMD restart # Restart services"
|
||||
echo " $COMPOSE_CMD down # Stop services"
|
||||
echo " $COMPOSE_CMD pull && $COMPOSE_CMD up -d # Update to latest"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Next Steps:${NC}"
|
||||
echo " 1. Open http://localhost:3000 in your browser"
|
||||
echo " 2. Configure AI Models (DeepSeek, OpenAI, etc.)"
|
||||
echo " 3. Configure Exchanges (Binance, Hyperliquid, etc.)"
|
||||
echo " 4. Create a Strategy in Strategy Studio"
|
||||
echo " 5. Create a Trader and start trading!"
|
||||
echo ""
|
||||
echo -e "${RED}⚠️ Risk Warning: AI trading carries significant risks.${NC}"
|
||||
echo -e "${RED} Only use funds you can afford to lose!${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main
|
||||
main() {
|
||||
check_docker
|
||||
setup_directory
|
||||
download_files
|
||||
generate_env
|
||||
pull_images
|
||||
start_services
|
||||
wait_for_services
|
||||
print_success
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user