-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (28 loc) · 873 Bytes
/
Dockerfile
File metadata and controls
41 lines (28 loc) · 873 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
34
35
36
37
38
39
40
41
# Stage 1: Build the React.js application
FROM node:20-alpine AS builder
# Accept build argument for VITE_APP_API
ARG VITE_APP_API
# Set environment variable for Vite
ENV VITE_APP_API=${VITE_APP_API}
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.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 built app with Nginx
FROM nginx:stable-alpine
# Remove default Nginx static assets
RUN rm -rf /usr/share/nginx/html/*
# Copy built files from the builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy your custom server configuration to conf.d
COPY default.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Start Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]