From 1c2044801e157d82947947137b35886efcba2b76 Mon Sep 17 00:00:00 2001 From: Christopher Hight Date: Fri, 2 Oct 2026 13:56:10 -0700 Subject: [PATCH] Added nginx for compile into proxy setup --- client/Dockerfile | 23 +++++++++++++++++++++++ client/nginx.conf | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 client/Dockerfile create mode 100644 client/nginx.conf diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..bd05f78 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,23 @@ +# Stage 1: The Node Builder +FROM node:20-alpine AS builder +WORKDIR /app + +# Install dependencies +COPY package*.json ./ +RUN npm ci + +# Copy React source code and build it +COPY . . +RUN npm run build + +# Stage 2: The Nginx Server +FROM nginx:alpine + +# Copy the compiled files from Stage 1 (Change /dist to /build if using Create-React-App instead of Vite) +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy your custom Nginx routing file +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..30408b0 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,23 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + # SPA routing: if a file isn't found, serve index.html + try_files $uri $uri/ /index.html; + } + + # Optional: Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + root /usr/share/nginx/html; + expires 1y; + add_header Cache-Control "public, no-transform"; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file