-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (26 loc) · 808 Bytes
/
Dockerfile
File metadata and controls
36 lines (26 loc) · 808 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
# Use Java 21 as the base image
FROM eclipse-temurin:21-jdk-alpine
# Set working directory
WORKDIR /app
# Copy the Maven pom.xml and install dependencies
COPY pom.xml .
COPY mvnw .
COPY .mvn .mvn
# Make the maven wrapper executable
RUN chmod +x ./mvnw
# Download dependencies (this layer will be cached unless pom.xml changes)
RUN ./mvnw dependency:go-offline -B
# Copy the source code
COPY src ./src
# Build the application
RUN ./mvnw package -DskipTests
# Use a smaller JRE runtime as the base image for the final image
FROM eclipse-temurin:21-jre-alpine
# Set working directory
WORKDIR /app
# Copy the built JAR file from the build stage
COPY --from=0 /app/target/*.jar app.jar
# Expose the port the app runs on
EXPOSE 8081
# Command to run the application
ENTRYPOINT ["java", "-jar", "app.jar"]