-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (19 loc) · 778 Bytes
/
Copy pathDockerfile
File metadata and controls
28 lines (19 loc) · 778 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
# Multi-stage Dockerfile for Spring Boot Application
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
# Copy POM and download dependencies for layer caching
COPY pom.xml .
RUN mvn dependency:go-offline -B
# Copy source code and build package
COPY src ./src
RUN mvn clean package -DskipTests
# Runtime stage
FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
# Create non-root user and uploads directory
RUN addgroup --system spring && adduser --system --ingroup spring spring
RUN mkdir -p /app/uploads && chown -R spring:spring /app
USER spring:spring
COPY --from=build /app/target/*.jar app.jar
ENV UPLOAD_DIR=/app/uploads
ENTRYPOINT ["sh", "-c", "java -Xmx320m -Xms128m -Xss256k -XX:+UseSerialGC -Dserver.port=${PORT:-8080} -Dserver.address=0.0.0.0 -jar app.jar"]