updates on the build file
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,17 +1,24 @@
|
|||||||
|
# Stage 1: Build the React application
|
||||||
|
FROM node:20-alpine AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy lock files and install dependencies
|
||||||
|
COPY package*.json yarn.lock* package-lock.json* ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy codebase and compile Vite project
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Serve using Nginx
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Move to Nginx's public folder
|
# Copy custom Nginx configuration
|
||||||
WORKDIR /usr/share/nginx/html
|
COPY nginx.config /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# 1. CRUCIAL: Remove Nginx's default "Welcome" page files completely
|
# Copy Vite's dist output from Stage 1 to Nginx default html path
|
||||||
RUN rm -rf ./*
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# 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 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ http {
|
|||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
# Next.js static export creates page.html (e.g. contact.html) for routes.
|
try_files $uri $uri/ /index.html;
|
||||||
# We check $uri.html to allow clean URLs without the .html extension.
|
|
||||||
try_files $uri $uri.html $uri/ /404.html;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user