-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (24 loc) · 1.02 KB
/
Dockerfile
File metadata and controls
34 lines (24 loc) · 1.02 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
# --- Build Stage ---
# Use a Maven image to build the application JAR. This keeps our final image small.
FROM maven:3.9-eclipse-temurin-21-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the Maven project files
COPY pom.xml .
COPY src ./src
# Build the application, skipping tests for faster builds in this context
RUN mvn clean package -DskipTests
# --- Final Stage ---
# Use a minimal, secure Java base image
FROM openjdk:21-slim
# Install curl for health checks
# The -y flag answers yes to prompts, and --no-install-recommends avoids installing extra packages
RUN apt-get update && apt-get install -y curl --no-install-recommends && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/*.jar app.jar
EXPOSE 8081
# Add the health check instruction
# It will try 5 times, with a 10s timeout, every 30s.
HEALTHCHECK --interval=30s --timeout=10s --retries=5 \
CMD curl -f http://localhost:8081/api/event-seating/health || exit 1
ENTRYPOINT ["java","-jar","/app/app.jar"]