File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed
Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change 1- # Use the official Nginx image from the Docker Hub
2- FROM nginx:latest
1+ # Stage 1: Build the Hugo site
2+ FROM node:20 AS builder
33
4- # Copy custom configuration file from the current directory
5- # to the Nginx configuration directory
4+ # Set working directory
5+ WORKDIR /app
6+
7+ # Copy package files
8+ COPY package*.json ./
9+
10+ # Install dependencies
11+ RUN npm install
12+
13+ # Copy all project files
14+ COPY . .
15+
16+ # Clean and build the Hugo site
17+ RUN npm run clean && npm run build
18+
19+ # Stage 2: Serve with Nginx
20+ FROM nginx:alpine
21+
22+ # Copy custom Nginx configuration
623COPY nginx.conf /etc/nginx/nginx.conf
724
8- # Copy website files to the default Nginx public directory
9- COPY public /usr/share/nginx/html
25+ # Copy built site from builder stage
26+ COPY --from=builder /app/ public /usr/share/nginx/html
1027
11- # Expose port 80 to the outside world
28+ # Expose port 80
1229EXPOSE 80
1330
14- # Start Nginx when the container has provisioned
31+ # Start Nginx
1532CMD ["nginx" , "-g" , "daemon off;" ]
You can’t perform that action at this time.
0 commit comments