-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (47 loc) · 2.33 KB
/
Dockerfile
File metadata and controls
58 lines (47 loc) · 2.33 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
# Stage 1: Build the application
FROM eclipse-temurin:25-jdk AS builder
# Install Node.js 24.x (required for Vaadin Hilla frontend build)
RUN apt-get update && apt-get install -y curl \
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Gradle wrapper and build files first (better layer caching)
COPY gradlew gradlew.bat ./
COPY gradle/ gradle/
COPY build.gradle.kts settings.gradle.kts ./
# Copy source code
COPY src/ src/
COPY package.json package-lock.json ./
COPY tsconfig.json vite.config.ts types.d.ts .env.production ./
COPY config/ config/
# Build the application (includes frontend via vaadinBuildFrontend)
RUN chmod +x gradlew && ./gradlew bootJar -Pvaadin.productionMode=true --no-daemon
# Stage 2: Runtime image (distroless)
FROM gcr.io/distroless/java25-debian13
WORKDIR /app
# Copy the built JAR, agents, and observability config from builder stage
COPY --from=builder /app/build/libs/*.jar app.jar
COPY --from=builder /app/build/otel-agent/grafana-opentelemetry-java.jar otel-agent.jar
COPY --from=builder /app/build/pyroscope-agent/pyroscope.jar pyroscope-agent.jar
COPY --from=builder /app/config/otel-agent.properties otel-agent.properties
# Distroless runs as non-root by default (uid 65532)
# JVM settings for 2GB container (distroless doesn't support JAVA_OPTS)
# - MaxRAMPercentage=60.0: ~1.2GB heap with room for metaspace + agents
# - MaxMetaspaceSize=256m: Headroom for Hibernate/Spring class loading
# - ReservedCodeCacheSize=128m: Room for JIT compilation
# - G1GC: Better throughput than SerialGC for larger heaps
# - Xss512k: Comfortable thread stack size
ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport \
-XX:MaxRAMPercentage=60.0 \
-XX:MaxMetaspaceSize=256m \
-XX:ReservedCodeCacheSize=128m \
-XX:+UseG1GC \
-Xss512k"
EXPOSE 8080
# Distroless has no shell, so use exec form
# OTEL: disable with OTEL_JAVAAGENT_ENABLED=false
# Pyroscope: disable by not setting PYROSCOPE_SERVER_ADDRESS
# OTEL: non-secret config in otel-agent.properties, secrets via Render env vars
# Pyroscope: non-secret config in otel-agent.properties, secrets via Render env vars
ENTRYPOINT ["java", "-javaagent:/app/otel-agent.jar", "-Dotel.javaagent.configuration-file=/app/otel-agent.properties", "-javaagent:/app/pyroscope-agent.jar", "-jar", "app.jar"]