|
1 | | -# Stage 1: Build the application |
2 | | -FROM node:20-alpine AS build |
3 | | - |
4 | | -# Set working directory inside container |
5 | | -WORKDIR /app |
6 | | - |
7 | | -# Copy package files first for better caching |
8 | | -COPY package.json yarn.lock ./ |
9 | | - |
10 | | -# Install dependencies with Yarn |
11 | | -RUN yarn install |
12 | | - |
13 | | -# Copy the rest of the application code |
14 | | -COPY . . |
15 | | - |
16 | | -# Build the Vue.js application |
17 | | -RUN yarn build |
18 | | - |
19 | | - |
20 | | -# Stage 2: Serve with a lightweight web server |
21 | | -FROM nginx:alpine |
22 | | - |
23 | | -# Copy built files from previous stage |
24 | | -COPY --from=build /app/dist /usr/share/nginx/html |
25 | | - |
26 | | -# Copy custom nginx config (optional) |
27 | | -# e.g., handles Vue router history mode |
28 | | -# Uncomment if you create nginx.conf |
29 | | -# COPY nginx.conf /etc/nginx/conf.d/default.conf |
30 | | - |
31 | | -# Expose port 80 |
32 | | -EXPOSE 80 |
33 | | - |
34 | | -# Start nginx server |
35 | | -CMD ["nginx", "-g", "daemon off;"] |
| 1 | +# Stage 1: Build the application |
| 2 | +FROM node:20-alpine AS build |
| 3 | + |
| 4 | +# Set working directory inside container |
| 5 | +WORKDIR /app |
| 6 | + |
| 7 | +# Copy package files first for better caching |
| 8 | +COPY package.json yarn.lock ./ |
| 9 | + |
| 10 | +# Install dependencies with Yarn |
| 11 | +RUN yarn install |
| 12 | + |
| 13 | +# Copy the rest of the application code |
| 14 | +COPY . . |
| 15 | + |
| 16 | +# Build the Vue.js application |
| 17 | +RUN yarn build |
| 18 | + |
| 19 | + |
| 20 | +# Stage 2: Serve with a lightweight web server |
| 21 | +FROM nginx:alpine |
| 22 | + |
| 23 | +# Copy built files from previous stage |
| 24 | +COPY --from=build /app/dist /usr/share/nginx/html |
| 25 | + |
| 26 | +# Copy custom nginx config |
| 27 | +# e.g., handles Vue router history mode |
| 28 | +COPY nginx.conf /etc/nginx/conf.d/default.conf |
| 29 | + |
| 30 | +# Expose port 80 |
| 31 | +EXPOSE 80 |
| 32 | + |
| 33 | +# Start nginx server |
| 34 | +CMD ["nginx", "-g", "daemon off;"] |
0 commit comments