-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (59 loc) · 2.98 KB
/
Dockerfile
File metadata and controls
77 lines (59 loc) · 2.98 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# syntax=docker/dockerfile:1
### Multi-stage Dockerfile for EventLens
###
### Platform: the *build* stage uses $BUILDPLATFORM (native builder). For a registry image
### that must be linux/amd64 from any host, run: docker build --platform linux/amd64 ...
###
### Gradle/npm: the host's ~/.gradle is NOT visible here. Cache mounts below reuse downloads
### between builds on the same machine (BuildKit / Podman 4+).
## 1) Build stage – compile and assemble the fat JAR
FROM --platform=$BUILDPLATFORM docker.io/library/eclipse-temurin:21-jdk AS build
# Install Node.js 20 LTS (needed by eventlens-ui for npm/Vite build)
RUN apt-get update && apt-get install -y curl && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Gradle wrapper and settings (better layer cache)
COPY settings.gradle.kts build.gradle.kts gradlew gradlew.bat ./
COPY gradle ./gradle
# Project sources
COPY eventlens-spi ./eventlens-spi
COPY eventlens-core ./eventlens-core
COPY eventlens-source-postgres ./eventlens-source-postgres
COPY eventlens-source-mysql ./eventlens-source-mysql
COPY eventlens-stream-kafka ./eventlens-stream-kafka
COPY eventlens-plugin-test ./eventlens-plugin-test
COPY eventlens-api ./eventlens-api
COPY eventlens-cli ./eventlens-cli
COPY eventlens-ui ./eventlens-ui
COPY eventlens-app ./eventlens-app
COPY eventlens.yaml.example ./eventlens.yaml
# Unix line endings + shaded JAR. --mount caches Gradle distro + deps and npm cache on the builder.
RUN --mount=type=cache,target=/root/.gradle \
--mount=type=cache,target=/root/.npm \
find . -type f \( -name "*.kts" -o -name "*.properties" -o -name "*.java" -o -name "*.kt" -o -name "*.xml" -o -name "*.yaml" -o -name "*.yml" -o -name "gradlew" \) -exec sed -i 's/\r$//' {} + \
&& chmod +x gradlew \
&& ./gradlew :eventlens-app:shadowJar -x test --no-daemon
## 2) Runtime stage – glibc-based JRE image for native-library compatibility
FROM docker.io/library/eclipse-temurin:21-jre-jammy AS base
ARG TARGETARCH
RUN groupadd --gid 1000 eventlens && \
useradd --uid 1000 --gid eventlens --shell /bin/bash --create-home eventlens
WORKDIR /app
# Copy the fat JAR from the build stage
COPY --from=build --chown=eventlens:eventlens /workspace/eventlens-app/build/libs/eventlens.jar /app/eventlens.jar
# Default configuration path (can be overridden with volume mounts or env)
COPY --from=build --chown=eventlens:eventlens /workspace/eventlens.yaml /app/eventlens.yaml
# Health check dependency
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
USER eventlens
EXPOSE 9090
ENV EVENTLENS_CONFIG=/app/eventlens.yaml
HEALTHCHECK --interval=10s --timeout=5s --retries=3 --start-period=20s \
CMD curl -sf http://localhost:9090/api/v1/health/live || exit 1
ENTRYPOINT ["java", \
"--enable-preview", \
"-XX:+UseG1GC", \
"-XX:MaxRAMPercentage=75.0", \
"-Djava.security.egd=file:/dev/urandom", \
"-jar", "/app/eventlens.jar"]