From c2c126d0cda1a05811daa9972f8d536b09c2d427 Mon Sep 17 00:00:00 2001 From: Michael Chihlas Date: Sat, 31 Jan 2026 23:29:05 -0500 Subject: [PATCH] Fix frontend nginx to use Railway PORT variable - Use envsubst to inject PORT at runtime - Template nginx.conf with ${PORT} placeholder Co-Authored-By: Claude Opus 4.5 --- frontend/Dockerfile | 10 ++++++---- frontend/nginx.conf | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 89c7f77a..675bcfd4 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -22,13 +22,15 @@ RUN npm run build # Production stage FROM nginx:alpine -# Copy custom nginx config -COPY nginx.conf /etc/nginx/conf.d/default.conf +# Copy custom nginx config template +COPY nginx.conf /etc/nginx/templates/default.conf.template # Copy built files from builder stage COPY --from=builder /app/dist /usr/share/nginx/html -# Expose port +# Railway uses PORT env variable (default to 80 for local) +ENV PORT=80 EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] +# Use envsubst to replace ${PORT} in nginx config, then start nginx +CMD sh -c "envsubst '\$PORT' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" diff --git a/frontend/nginx.conf b/frontend/nginx.conf index bdfe966e..e005e331 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -1,5 +1,5 @@ server { - listen 80; + listen ${PORT}; server_name _; root /usr/share/nginx/html; index index.html;