-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (33 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
48 lines (33 loc) · 1.1 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
# Multi-stage build for Java Spring Boot application
FROM eclipse-temurin:25-jdk AS builder
# Install Maven
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy pom.xml
COPY pom.xml .
# Download dependencies (this layer will be cached unless pom.xml changes)
RUN mvn dependency:go-offline -B
# Copy source code
COPY src src
# Build the application
RUN mvn clean package -DskipTests -B
# Production stage
FROM eclipse-temurin:25-jre
# Set working directory
WORKDIR /app
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Copy the built JAR from builder stage
COPY --from=builder /app/target/open-meteo-mcp-*.jar app.jar
# Change ownership of the app directory to appuser
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose the port the app runs on
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]