fix: use Railway PORT env var for nginx

This commit is contained in:
tinkle-community
2026-01-06 18:07:11 +08:00
parent 7db37ade1c
commit 29cd79c626
4 changed files with 22 additions and 5 deletions

View File

@@ -66,7 +66,7 @@ RUN npm run build
FROM alpine:${ALPINE_VERSION}
RUN apk update && apk add --no-cache \
ca-certificates tzdata sqlite nginx supervisor openssl
ca-certificates tzdata sqlite nginx supervisor openssl gettext
# Copy TA-Lib
COPY --from=ta-lib-builder /usr/local /usr/local
@@ -78,8 +78,12 @@ 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 Railway-specific nginx config template
COPY railway/nginx.conf.template /etc/nginx/nginx.conf.template
# Copy nginx startup wrapper
COPY railway/start-nginx.sh /app/start-nginx.sh
RUN chmod +x /app/start-nginx.sh
# Copy supervisor config
COPY railway/supervisord.conf /etc/supervisord.conf

View File

@@ -2,7 +2,7 @@
# Frontend static files + API proxy to backend
server {
listen 8080;
listen ${PORT};
server_name _;
root /usr/share/nginx/html;

13
railway/start-nginx.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# Nginx startup wrapper - substitutes PORT environment variable
# Default PORT to 8080 if not set
export PORT=${PORT:-8080}
echo "🌐 Starting nginx on port $PORT..."
# Generate nginx config from template
envsubst '${PORT}' < /etc/nginx/nginx.conf.template > /etc/nginx/http.d/default.conf
# Start nginx
exec nginx -g "daemon off;"

View File

@@ -16,7 +16,7 @@ stderr_logfile_maxbytes=0
environment=API_SERVER_PORT="8081",DB_PATH="/app/data/data.db"
[program:nginx]
command=nginx -g "daemon off;"
command=/app/start-nginx.sh
autostart=true
autorestart=true
stdout_logfile=/dev/stdout