-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (28 loc) · 785 Bytes
/
Dockerfile
File metadata and controls
40 lines (28 loc) · 785 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
37
38
39
40
# Use OpenJDK 17 as base image
FROM openjdk:17-jdk-slim
# Set working directory
WORKDIR /app
# Copy Maven wrapper and pom.xml
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
# Make Maven wrapper executable
RUN chmod +x mvnw
# Download dependencies (this layer will be cached if pom.xml doesn't change)
RUN ./mvnw dependency:go-offline -B
# Copy source code
COPY src src
# Build the application
RUN ./mvnw clean package -DskipTests
# Create a new stage for runtime
FROM openjdk:17-jre-slim
# Set working directory
WORKDIR /app
# Copy the built JAR from the build stage
COPY --from=0 /app/target/*.jar app.jar
# Expose port
EXPOSE 8080
# Set JVM options for production
ENV JAVA_OPTS="-Xmx512m -Xms256m"
# Run the application
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]