feat: add Railway one-click deployment support

- Add Dockerfile.railway for all-in-one container
- Add railway.toml configuration
- Add railway/nginx.conf and supervisord.conf
- Update README with Deploy on Railway button
- Update Chinese README with deployment instructions
This commit is contained in:
tinkle-community
2026-01-06 17:32:09 +08:00
parent 799d8b9c2e
commit 4804cfcb05
6 changed files with 202 additions and 2 deletions
+99
View File
@@ -0,0 +1,99 @@
# NOFX Railway Deployment
# All-in-one Dockerfile for one-click Railway deployment
# Combines backend + frontend in a single container
ARG GO_VERSION=1.25-alpine
ARG NODE_VERSION=20-alpine
ARG ALPINE_VERSION=latest
ARG TA_LIB_VERSION=0.4.0
# ──────────────────────────────────────────────────────────────
# Stage 1: TA-Lib Build
# ──────────────────────────────────────────────────────────────
FROM alpine:${ALPINE_VERSION} AS ta-lib-builder
ARG TA_LIB_VERSION
RUN apk update && apk add --no-cache \
wget tar make gcc g++ musl-dev autoconf automake
RUN wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-${TA_LIB_VERSION}-src.tar.gz && \
tar -xzf ta-lib-${TA_LIB_VERSION}-src.tar.gz && \
cd ta-lib && \
if [ "$(uname -m)" = "aarch64" ]; then \
CONFIG_GUESS=$(find /usr/share -name config.guess | head -1) && \
CONFIG_SUB=$(find /usr/share -name config.sub | head -1) && \
cp "$CONFIG_GUESS" config.guess && \
cp "$CONFIG_SUB" config.sub && \
chmod +x config.guess config.sub; \
fi && \
./configure --prefix=/usr/local && \
make && make install && \
cd .. && rm -rf ta-lib ta-lib-${TA_LIB_VERSION}-src.tar.gz
# ──────────────────────────────────────────────────────────────
# Stage 2: Backend Build (Go)
# ──────────────────────────────────────────────────────────────
FROM golang:${GO_VERSION} AS backend-builder
RUN apk update && apk add --no-cache git make gcc g++ musl-dev
COPY --from=ta-lib-builder /usr/local /usr/local
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=1 GOOS=linux \
CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \
go build -trimpath -ldflags="-s -w" -o nofx .
# ──────────────────────────────────────────────────────────────
# Stage 3: Frontend Build (Node)
# ──────────────────────────────────────────────────────────────
FROM node:${NODE_VERSION} AS frontend-builder
WORKDIR /build
COPY web/package*.json ./
RUN npm ci
COPY web/ ./
RUN npm run build
# ──────────────────────────────────────────────────────────────
# Stage 4: Runtime (All-in-one)
# ──────────────────────────────────────────────────────────────
FROM alpine:${ALPINE_VERSION}
RUN apk update && apk add --no-cache \
ca-certificates tzdata sqlite nginx supervisor
# Copy TA-Lib
COPY --from=ta-lib-builder /usr/local /usr/local
# Copy backend binary
WORKDIR /app
COPY --from=backend-builder /app/nofx .
# Copy frontend build
COPY --from=frontend-builder /build/dist /usr/share/nginx/html
# Copy Railway-specific nginx config
COPY railway/nginx.conf /etc/nginx/http.d/default.conf
# Copy supervisor config
COPY railway/supervisord.conf /etc/supervisord.conf
# Create data directory
RUN mkdir -p /app/data
# Railway uses PORT env var, default to 8080
ENV PORT=8080
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
+9 -1
View File
@@ -133,7 +133,15 @@ To use NOFX, you'll need:
## Quick Start ## Quick Start
### One-Click Install (Recommended) ### One-Click Cloud Deploy (Easiest)
Deploy to Railway with one click - no server setup required:
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/NoFxAiOS/nofx&referralCode=nofx)
After deployment, Railway will provide a public URL to access your NOFX instance.
### One-Click Install (Local)
**Linux / macOS:** **Linux / macOS:**
```bash ```bash
+9 -1
View File
@@ -104,7 +104,15 @@
## 快速开始 ## 快速开始
### 一键安装 (推荐) ### 一键云部署 (最简单)
一键部署到 Railway - 无需自己搭建服务器:
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template?template=https://github.com/NoFxAiOS/nofx&referralCode=nofx)
部署后,Railway 会提供一个公网 URL 访问你的 NOFX 实例。
### 一键安装 (本地)
**Linux / macOS:** **Linux / macOS:**
```bash ```bash
+8
View File
@@ -0,0 +1,8 @@
[build]
dockerfilePath = "Dockerfile.railway"
[deploy]
healthcheckPath = "/health"
healthcheckTimeout = 60
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 3
+52
View File
@@ -0,0 +1,52 @@
# Railway Nginx Configuration
# Frontend static files + API proxy to backend
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
# Frontend routes (SPA)
location / {
try_files $uri $uri/ /index.html;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
# Proxy API requests to backend (runs on 8081 internally)
location /api/ {
proxy_pass http://127.0.0.1:8081/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;
# Timeout for long-running API calls (AI inference)
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
# Health check endpoint
location /health {
return 200 "OK\n";
add_header Content-Type text/plain;
access_log off;
}
}
+25
View File
@@ -0,0 +1,25 @@
[supervisord]
nodaemon=true
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/tmp/supervisord.pid
[program:backend]
command=/app/nofx
directory=/app
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=API_SERVER_PORT="8081",DB_PATH="/app/data/data.db"
[program:nginx]
command=nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0