File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1- # Use the latest nginx as the base image
1+ # Stage 1: Build the Nuxt.js app
2+ FROM node:18-alpine AS build-stage
3+
4+ # Set the working directory
5+ WORKDIR /app
6+
7+ # Copy package.json and package-lock.json
8+ COPY package*.json ./
9+
10+ # Install dependencies
11+ RUN npm install
12+
13+ # Copy the rest of the application code
14+ COPY . .
15+
16+ # Build the application for static hosting
17+ RUN npm run generate
18+
19+ # Stage 2: Serve the static files using Nginx
220FROM nginx:1.27.3
321
422# Set environment variables
@@ -13,8 +31,8 @@ RUN groupadd -r frontenduser && useradd -r -g frontenduser frontenduser
1331# Create a directory for the PID file and assign ownership to frontenduser
1432RUN mkdir -p /var/run/nginx && chown -R frontenduser:frontenduser /var/run/nginx
1533
16- # Copy all files to the container
17- COPY . /usr/share/nginx/html
34+ # Copy the generated static files from the build stage
35+ COPY --from=build-stage /app/dist /usr/share/nginx/html
1836
1937# Copy nginx.conf to a writable location and modify the PID path
2038RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.custom && \
You can’t perform that action at this time.
0 commit comments