-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.68 KB
/
Dockerfile
File metadata and controls
45 lines (33 loc) · 1.68 KB
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
42
43
44
45
# --------------------------------------------------------------------------------
# Stage 1: Build Stage (Handles Dependencies and React Compilation)
# --------------------------------------------------------------------------------
FROM node:20-alpine AS builder
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies. This installs all devDependencies required for the build.
RUN npm install
# *** FIX: Explicitly install autoprefixer to resolve the missing module error ***
RUN npm install autoprefixer
# Copy the rest of the application source code
COPY . .
# CRITICAL: Build the React application into static files.
# For Vite, this creates a 'dist' folder by default.
RUN npm run build
# --------------------------------------------------------------------------------
# Stage 2: Production Stage (Minimal Server and Built Assets)
# --------------------------------------------------------------------------------
FROM node:20-alpine AS final
# Install 'serve' globally to act as the lightweight web server
RUN npm install -g serve
# Set the working directory
WORKDIR /app
# *** FIX APPLIED HERE: Changed 'build' to 'dist' ***
# Copy the built application from the 'builder' stage's /app/dist directory
COPY --from=builder /app/dist ./dist
# Expose the port the server will run on
EXPOSE 80
# *** FIX APPLIED HERE: Changed 'build' to 'dist' ***
# Run the 'serve' command to host the built application from the 'dist' folder.
CMD ["serve", "-s", "dist", "-l", "80"]