-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (22 loc) · 698 Bytes
/
Dockerfile
File metadata and controls
32 lines (22 loc) · 698 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
# Use an official Node.js image as the base (LTS version for stability)
FROM node:18-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json first (Leverage Docker cache)
COPY package*.json ./
# Install dependencies in a clean environment
RUN npm ci --only=production
# Copy the rest of the application source code
COPY . .
# Build the React app
RUN npm run build
# ---- Production Stage ----
FROM node:18-alpine
# Set the working directory
WORKDIR /app
# Copy the built React app from the builder stage
COPY --from=builder /app .
# Expose the port the app runs on
EXPOSE 3000
# Start the application
CMD ["npm", "start"]