diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df108a3 --- /dev/null +++ b/Dockerfile @@ -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;"] + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..2d1953f --- /dev/null +++ b/nginx.conf @@ -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; + } + } +}