-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (36 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
51 lines (36 loc) · 1.16 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
# Multi-stage build for Data Lake Receiver
# Stage 1: Build the application
FROM maven:3.9-eclipse-temurin-17-alpine AS builder
WORKDIR /build
# Copy Maven files for dependency caching
COPY pom.xml .
# Download dependencies (cached layer)
RUN mvn dependency:go-offline -B
# Copy source code
COPY src ./src
# Build the application (skip tests for faster builds)
RUN mvn clean package -DskipTests -B
# Stage 2: Runtime image
FROM eclipse-temurin:17-jre-alpine
# Set working directory
WORKDIR /app
# Install curl for healthchecks
RUN apk add --no-cache curl
# Create non-root user for security
RUN addgroup -g 1000 appuser && \
adduser -D -u 1000 -G appuser appuser && \
mkdir -p /app/data/files && \
chown -R appuser:appuser /app
# Copy the JAR from builder stage
COPY --from=builder /build/target/datalake-receiver-*.jar app.jar
# Change ownership
RUN chown appuser:appuser app.jar
# Switch to non-root user
USER appuser
# Expose the application port
EXPOSE 4000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:4000/health || exit 1
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]