-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (27 loc) · 842 Bytes
/
Copy pathDockerfile
File metadata and controls
33 lines (27 loc) · 842 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 JAR
# ----------------------------
# Use a Maven image that comes with Java 17 pre-installed
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
# Copy pom.xml and source code
COPY pom.xml .
COPY src ./src
# Build the application
RUN mvn clean package -DskipTests
# ----------------------------
# STAGE 2: Run the App
# ----------------------------
# Use Eclipse Temurin (The new standard for OpenJDK)
FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
# 🟢 Install C++ (g++) and Python (Critical for Native Execution)
RUN apt-get update && apt-get install -y \
g++ \
python3 \
&& rm -rf /var/lib/apt/lists/*
# Copy the built JAR from the previous stage
COPY --from=build /app/target/*.jar app.jar
# Expose port and run
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]