forked from TheChance101/MENA-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (23 loc) · 717 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (23 loc) · 717 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
FROM eclipse-temurin:17-jdk as builder
WORKDIR /app
# Copy only necessary files first for better caching
COPY gradlew .
COPY gradle gradle
COPY build.gradle.kts .
COPY settings.gradle.kts .
# Download dependencies
RUN ./gradlew build --no-daemon --stacktrace -x test || return 0
# Copy the rest of the source code
COPY . .
# Ensure gradlew is executable
RUN chmod +x gradlew
# Build the application
RUN ./gradlew :app:bootJar --no-daemon
# ---- Stage 2: Run the application ----
FROM eclipse-temurin:17-jre
WORKDIR /app
# Copy the generated JAR from the builder image
COPY --from=builder app/app/build/libs/*.jar app.jar
# Expose Spring Boot default port
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]