-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (24 loc) · 757 Bytes
/
Dockerfile
File metadata and controls
33 lines (24 loc) · 757 Bytes
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
# Stage 1: Build the React application
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application source code
COPY . .
# Build the application
RUN npm run build
# Stage 2: Serve the application with Vite
FROM node:20-alpine
WORKDIR /app
# Copy built assets and package files from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/vite.config.ts ./
# Install dependencies to run the preview server
RUN npm install
# Expose the port Vite preview runs on
EXPOSE 4173
# Start the Vite preview server
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0"]