-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 826 Bytes
/
Dockerfile
File metadata and controls
36 lines (25 loc) · 826 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
# ==============================
# STAGE 1: Build with Maven
# ==============================
FROM maven:3.9.11-eclipse-temurin-21 AS build
WORKDIR /app
# Copy only Maven config files first to leverage Docker cache
COPY pom.xml ./
# Cache Maven dependencies
RUN mvn dependency:go-offline -B
# Copy full source code
COPY src ./src
# Build Spring Boot jar
RUN mvn clean package -Pprod -DskipTests
# ==============================
# STAGE 2: Run JAR
# ==============================
FROM openjdk:21-jdk-slim
WORKDIR /app
# Install wget for health check
RUN apt-get update && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/*
# Copy Spring Boot JAR from the build stage
COPY --from=build /app/target/gateway-*.jar app.jar
EXPOSE 8080
# Start Spring Boot app
CMD ["java", "-jar", "app.jar"]