-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (21 loc) · 1.06 KB
/
Copy pathDockerfile
File metadata and controls
28 lines (21 loc) · 1.06 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
# ─── Build Stage ─────────────────────────────────────────────────────────────
FROM maven:3.9.6-eclipse-temurin-21-alpine AS builder
WORKDIR /app
# Cache Maven dependencies by copying pom.xml first
COPY pom.xml .
RUN mvn dependency:go-offline -B
# Copy sources and package the application
COPY src ./src
RUN mvn package -DskipTests
# ─── Run Stage ───────────────────────────────────────────────────────────────
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# Create a non-root system user and group for security
RUN addgroup -S ems && adduser -S ems -G ems
USER ems
# Copy the packaged jar from the builder stage
COPY --from=builder /app/target/employee-management-system-0.0.1-SNAPSHOT.jar app.jar
# Expose Spring Boot default port
EXPOSE 8080
# Run the Spring Boot application
ENTRYPOINT ["java", "-jar", "app.jar"]