-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (22 loc) · 841 Bytes
/
Dockerfile
File metadata and controls
33 lines (22 loc) · 841 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
# --- STAGE 1: Build the Application ---
FROM maven:3.9.6-eclipse-temurin-21 AS build
# Set the working directory
WORKDIR /app
# Copy the pom.xml file first to cache dependencies layer
COPY pom.xml .
# Download dependencies (uses the cached layer if pom.xml hasn't changed)
RUN mvn dependency:go-offline
# Copy the rest of the source code
COPY src ./src
# Build the final JAR file
RUN mvn package -DskipTests
# --- STAGE 2: Create the Final, Smaller Runtime Image ---
# Use a lightweight JRE (Java Runtime Environment) base image for the final container
FROM eclipse-temurin:21-jre-alpine
# Set the working directory
WORKDIR /tag
# Copy the final JAR from the 'build' stage
COPY --from=build /app/target/TAG.jar /tag/TAG.jar
# Copy data files required for some games
COPY data /tag/data
ENTRYPOINT ["java", "-jar", "/tag/TAG.jar"]