Spaces:
Configuration error
Configuration error
Bimo Abdul Aziz commited on
Commit ·
1fd4096
1
Parent(s): 73c2e44
Add multi-stage Dockerfile for Java app
Browse filesIntroduce a multi-stage Dockerfile: stage 1 uses maven:3.9.9-eclipse-temurin-25 to build the project (mvn clean package -DskipTests); stage 2 uses eclipse-temurin:25-jre-alpine as a lightweight runtime. The built target/*.jar is copied to app.jar, port 8080 is exposed (Render default), and the container runs with ENTRYPOINT ["java","-jar","app.jar"]. This separates build and runtime to produce a smaller runtime image.
- Dockerfile +16 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Stage 1: Build program menggunakan Maven & JDK 25
|
| 3 |
+
FROM maven:3.9.9-eclipse-temurin-25 AS build
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
COPY . .
|
| 6 |
+
RUN mvn clean package -DskipTests
|
| 7 |
+
|
| 8 |
+
# Stage 2: Jalankan aplikasi menggunakan JRE 25 yang ringan
|
| 9 |
+
FROM eclipse-temurin:25-jre-alpine
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
COPY --from=build /app/target/*.jar app.jar
|
| 12 |
+
|
| 13 |
+
# Port default yang dibaca oleh Render
|
| 14 |
+
EXPOSE 8080
|
| 15 |
+
|
| 16 |
+
ENTRYPOINT ["java", "-jar", "app.jar"]
|