-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (47 loc) · 1.52 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (47 loc) · 1.52 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# ==========================================
# STAGE 1: Build React Frontend
# ==========================================
FROM node:20-alpine AS frontend-builder
WORKDIR /app/client
# Copy package.json and install dependencies
COPY client/package*.json ./
RUN npm install
# Copy source and build
COPY client/ ./
RUN npm run build
# ==========================================
# STAGE 2: Build Spring Boot Backend
# ==========================================
FROM eclipse-temurin:21-jdk-jammy AS backend-builder
WORKDIR /app/api
# Copy Maven wrapper and POM
COPY api/mvnw .
COPY api/.mvn .mvn
COPY api/pom.xml .
# Make wrapper executable
RUN chmod +x mvnw
# Download dependencies (cache layer)
RUN ./mvnw dependency:go-offline
# Copy API source
COPY api/src src
# Copy the built React app into Spring Boot's static resources folder
COPY --from=frontend-builder /app/client/dist src/main/resources/static/
# Build the unified JAR
RUN ./mvnw clean package -DskipTests
# ==========================================
# STAGE 3: Final Production Image
# ==========================================
FROM eclipse-temurin:21-jdk-jammy
WORKDIR /app
# 🟢 CRITICAL: Install C++ (g++), Python, and GNU time for real memory metrics
RUN apt-get update && apt-get install -y \
g++ \
python3 \
time \
&& rm -rf /var/lib/apt/lists/*
# Copy the unified JAR from the backend-builder
COPY --from=backend-builder /app/api/target/api-0.0.1-SNAPSHOT.jar app.jar
# Expose port
EXPOSE 8080
# Run the unified application
ENTRYPOINT ["java", "-jar", "app.jar"]