Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.43 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (36 loc) · 1.43 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# ---------- Build stage ----------
FROM maven:3.9.9-eclipse-temurin-21 AS builder
WORKDIR /workspace
# Copy only pom first to leverage Docker layer caching for dependencies
COPY pom.xml ./
# Pre-fetch dependencies (offline) to speed up subsequent builds
RUN mvn -B -q -DskipTests dependency:go-offline
# Now copy the source and build
COPY src ./src
# Build the application (skip tests for faster image builds)
RUN mvn -B -DskipTests clean package
# ---------- Runtime stage ----------
FROM eclipse-temurin:21-jre-alpine
# Create non-root user
RUN addgroup -S spring && adduser -S spring -G spring
WORKDIR /app
# Copy the fat jar from the builder image
# Adjust name if your artifactId/version changes
COPY --from=builder /workspace/target/evently-0.0.1-SNAPSHOT.jar /app/app.jar
# Default environment variables (can be overridden at runtime)
ENV SPRING_PROFILES_ACTIVE=default \
SPRING_APP_NAME=evently \
DATABASE_URL=jdbc:postgresql://localhost:5432/evently_db \
REDIS_URL=redis://localhost:6379 \
FLYWAY_ENABLED=true \
TZ=Asia/Kolkata
# Install timezone support
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime && \
echo "Asia/Kolkata" > /etc/timezone
# Expose the application port
EXPOSE 8080
# Use non-root user
USER spring
# JVM tuned for containers; Spring Boot jar execution
ENTRYPOINT ["java","-XX:MaxRAMPercentage=75.0","-Duser.timezone=Asia/Kolkata","-jar","/app/app.jar"]