From 46f70815af5a77914976777b9f785bf8e3a967cd Mon Sep 17 00:00:00 2001 From: Aravind Date: Tue, 14 Jul 2026 11:06:01 +0530 Subject: [PATCH] gateway issue --- Dockerfile | 38 ++++++++++++-------------------------- nginx.conf | 8 ++------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 055a4ea..cd72498 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,12 @@ -FROM node:20-alpine - -WORKDIR /app - -# Next.js standalone runtime. Required because the contact form's Server -# Action (sendEmail.ts, SMTP via nodemailer) needs a live Node process - -# it cannot run under static/nginx serving. -ENV NODE_ENV=production -ENV PORT=3000 -ENV HOSTNAME=0.0.0.0 - -# Copy the standalone build artifact (server.js, .next/, public/) -COPY build /app - -# The standalone build was created on macOS (darwin-arm64), so it bundles -# macOS-only native binaries for sharp (image optimisation). These crash -# on Linux/Alpine. Replace them with the correct musl-linux-x64 binaries. -RUN rm -rf node_modules/@img/sharp-darwin-arm64 \ - node_modules/@img/sharp-libvips-darwin-arm64 && \ - npm install --no-save --platform=linuxmusl --arch=x64 \ - @img/sharp-linuxmusl-x64@0.34.5 && \ - rm -rf /tmp/* /root/.npm - -EXPOSE 3000 - -CMD ["node", "server.js"] +FROM nginx:alpine +# Move to Nginx's public folder +WORKDIR /usr/share/nginx/html +# 1. CRUCIAL: Remove Nginx's default "Welcome" page files completely +RUN rm -rf ./* +# 2. Copy your compiled static assets into the root folder. +# NOTE: If your folder is named "dist" instead of "build", change "build/" to "dist/" +COPY build/ . +# 3. Copy your custom Nginx configuration (which you already have in your log) +COPY nginx.conf /etc/nginx/nginx.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 64575b6..5df226f 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,19 +1,15 @@ events {} - http { include /etc/nginx/mime.types; default_type application/octet-stream; - server { listen 80; server_name localhost; - location / { root /usr/share/nginx/html; index index.html index.htm; - # Next.js static export creates page.html (e.g. contact.html) for routes. - # We check $uri.html to allow clean URLs without the .html extension. - try_files $uri $uri.html $uri/ /404.html; + # This line forces Nginx to pass routing back to React Router + try_files $uri $uri/ /index.html; } } }