-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (24 loc) · 796 Bytes
/
Dockerfile
File metadata and controls
35 lines (24 loc) · 796 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
35
# Build stage
FROM eclipse-temurin:21-jdk-alpine AS builder
WORKDIR /app
# Copy Gradle wrapper and build scripts first (better layer caching)
COPY gradlew .
COPY gradle/ gradle/
COPY build.gradle.kts .
COPY settings.gradle.kts .
COPY gradle.properties .
# Make gradlew executable and pre-download dependencies
RUN chmod +x gradlew && ./gradlew dependencies --no-daemon || true
# Copy source and build the JAR
COPY src/ src/
RUN ./gradlew jar --no-daemon
# Run the app!
FROM eclipse-temurin:21-jre-alpine
ARG JARFILE="trakt-1.0-SNAPSHOT.jar"
WORKDIR /app
# Create a non-root user for security
RUN addgroup -S trakt && adduser -S trakt -G trakt
# Copy the fat JAR from the build stage
COPY --from=builder /app/build/libs/${JARFILE} trakt.jar
USER trakt
CMD ["java", "-jar", "trakt.jar"]