This commit is contained in:
2026-07-08 16:45:06 +05:30
2 changed files with 47 additions and 0 deletions

29
Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# --- Step 1: Build the React Application ---
FROM node:20-alpine AS build-stage
WORKDIR /app
# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci
# Copy source files and build
COPY . .
RUN npm run build
# --- Step 2: Serve the Built Assets via Nginx ---
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
# Clean default Nginx files
RUN rm -rf ./*
# Copy built assets from Stage 1 (Vite default output is "dist")
COPY --from=build-stage /app/dist .
# Copy custom Nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]

18
nginx.conf Normal file
View File

@@ -0,0 +1,18 @@
events {}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 3000;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
# This line forces Nginx to pass routing back to React Router
try_files $uri $uri/ /index.html;
}
}
}