Files
nofx/railway/start.sh
tinkle-community 6e6bdf1e57 refactor: simplify Railway deployment using existing GHCR images
- Use multi-stage build from existing backend/frontend images
- Remove supervisord, use simple shell script
- Single process model: backend runs in background, nginx foreground
- Auto-generate encryption keys on startup
2026-01-06 18:31:39 +08:00

42 lines
1020 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -e
# 默认端口
export PORT=${PORT:-3000}
echo "🚀 Starting NOFX on port $PORT..."
# 生成加密密钥(如果没有设置)
if [ -z "$RSA_PRIVATE_KEY" ]; then
echo "🔐 Generating RSA key..."
export RSA_PRIVATE_KEY=$(openssl genrsa 2048 2>/dev/null)
fi
if [ -z "$DATA_ENCRYPTION_KEY" ]; then
echo "🔐 Generating data encryption key..."
export DATA_ENCRYPTION_KEY=$(openssl rand -base64 32)
fi
# 生成 nginx 配置
echo "📝 Generating nginx config for port $PORT..."
envsubst '${PORT}' < /etc/nginx/nginx.conf.template > /etc/nginx/http.d/default.conf
# 启动后端(后台运行)
echo "🔧 Starting backend on port 8080..."
/app/nofx &
BACKEND_PID=$!
# 等待后端启动
sleep 3
# 检查后端是否启动成功
if ! kill -0 $BACKEND_PID 2>/dev/null; then
echo "❌ Backend failed to start"
exit 1
fi
echo "✅ Backend started (PID: $BACKEND_PID)"
# 启动 nginx前台运行
echo "🌐 Starting nginx on port $PORT..."
exec nginx -g "daemon off;"