-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (24 loc) · 838 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Stage 1: Build the application
FROM node:18 AS build
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json to install dependencies
COPY package.json package-lock.json ./
# Clean up any existing node_modules and lock files
RUN rm -rf node_modules package-lock.json
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Serve the application using a lightweight web server (nginx)
FROM nginx:alpine AS production
# Copy the build output from the previous stage to nginx's web directory
COPY --from=build /app/dist /usr/share/nginx/html
# Copy nginx config to serve the Vite application (optional)
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]