File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # ---- Stage 1: Build ----
2+ # Uses the full JDK image to compile the application with Maven
3+ FROM eclipse-temurin:25-jdk AS build
4+ WORKDIR /app
5+
6+ # Copy Maven wrapper and pom.xml first to leverage Docker layer caching
7+ # Dependencies are downloaded only when pom.xml changes
8+ COPY mvnw pom.xml ./
9+ COPY .mvn .mvn
10+ RUN chmod +x mvnw && ./mvnw dependency:go-offline -B
11+
12+ # Copy source code and build the JAR (tests are skipped as they run in CI)
13+ COPY src src
14+ RUN ./mvnw package -DskipTests -B
15+
16+ # ---- Stage 2: Run ----
17+ # Uses a lightweight JRE-only image for a smaller and more secure final image
18+ FROM eclipse-temurin:25-jre
19+ WORKDIR /app
20+
21+ # Copy the built JAR from the build stage
22+ COPY --from=build /app/target/*.jar app.jar
23+
24+ # Document the port the application listens on
25+ EXPOSE 8080
26+
27+ # Start the Spring Boot application
28+ ENTRYPOINT ["java" , "-jar" , "app.jar" ]
Original file line number Diff line number Diff line change @@ -18,6 +18,28 @@ services:
1818 networks :
1919 - xpeho_network
2020
21+ app :
22+ build :
23+ context : .
24+ dockerfile : Dockerfile
25+ container_name : xpeho_app
26+ environment :
27+ POSTGRES_USER : ${POSTGRES_USER}
28+ POSTGRES_PASSWORD : ${POSTGRES_PASSWORD}
29+ POSTGRES_DB : ${POSTGRES_DB}
30+ POSTGRES_PORT : 5432
31+ SPRING_DATASOURCE_URL : jdbc:postgresql://postgres:5432/${POSTGRES_DB}
32+ SPRING_LIQUIBASE_ENABLED : ${SPRING_LIQUIBASE_ENABLED:-true}
33+ LB_CHANGELOG : ${LB_CHANGELOG}
34+ LB_SCHEMA : ${LB_SCHEMA}
35+ ports :
36+ - " 8080:8080"
37+ depends_on :
38+ postgres :
39+ condition : service_healthy
40+ networks :
41+ - xpeho_network
42+
2143volumes :
2244 postgres_data :
2345 driver : local
You can’t perform that action at this time.
0 commit comments