Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/ad/Dockerfile.elastic
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ RUN ./gradlew installDist -PprotoSourceDir=./proto

# -----------------------------------------------------------------------------

# fetch latest published snapshot of the Elastic OpenTelemetry Java agent, using xq to parse XML
FROM eclipse-temurin:21-jre AS intermediate
RUN <<-EOF
apt-get update && apt-get install -y xq
artifact='elastic-otel-javaagent'
base_url="https://central.sonatype.com/repository/maven-snapshots/co/elastic/otel/${artifact}"
snapshot_version="$(curl -s "${base_url}/maven-metadata.xml" | xq -e metadata/versioning/latest)"
snapshot_timestamp="$(curl -s "${base_url}/${snapshot_version}/maven-metadata.xml" | xq -e metadata/versioning/snapshot/timestamp)"
snapshot_buildnumber="$(curl -s "${base_url}/${snapshot_version}/maven-metadata.xml" | xq -e metadata/versioning/snapshot/buildNumber)"
curl \
-o /opentelemetry-javaagent.jar \
"${base_url}/${snapshot_version}/${artifact}-${snapshot_version%-SNAPSHOT}-${snapshot_timestamp}-${snapshot_buildnumber}.jar"
EOF

# -----------------------------------------------------------------------------

FROM eclipse-temurin:21-jre

# ARG version=0.4.0
Expand All @@ -24,7 +40,9 @@ ARG _JAVA_OPTIONS
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/ ./
ADD --chmod=644 https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=co.elastic.otel&a=elastic-otel-javaagent&v=LATEST /usr/src/app/opentelemetry-javaagent.jar

COPY --from=intermediate /opentelemetry-javaagent.jar /usr/src/app/opentelemetry-javaagent.jar

ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar
ENV OTEL_INFERRED_SPANS_ENABLED=true
ENV ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION=2
Expand Down
21 changes: 19 additions & 2 deletions src/fraud-detection/Dockerfile.elastic
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,30 @@ RUN gradle shadowJar

# -----------------------------------------------------------------------------

FROM gcr.io/distroless/java17-debian11
# fetch latest published snapshot of the Elastic OpenTelemetry Java agent, using xq to parse XML
FROM eclipse-temurin:21-jre AS intermediate
RUN <<-EOF
apt-get update && apt-get install -y xq
artifact='elastic-otel-javaagent'
base_url="https://central.sonatype.com/repository/maven-snapshots/co/elastic/otel/${artifact}"
snapshot_version="$(curl -s "${base_url}/maven-metadata.xml" | xq -e metadata/versioning/latest)"
snapshot_timestamp="$(curl -s "${base_url}/${snapshot_version}/maven-metadata.xml" | xq -e metadata/versioning/snapshot/timestamp)"
snapshot_buildnumber="$(curl -s "${base_url}/${snapshot_version}/maven-metadata.xml" | xq -e metadata/versioning/snapshot/buildNumber)"
curl \
-o /opentelemetry-javaagent.jar \
"${base_url}/${snapshot_version}/${artifact}-${snapshot_version%-SNAPSHOT}-${snapshot_timestamp}-${snapshot_buildnumber}.jar"
EOF

# -----------------------------------------------------------------------------

FROM gcr.io/distroless/java17-debian12:nonroot

# ARG version=0.4.0
WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/build/libs/fraud-detection-1.0-all.jar ./
ADD --chmod=644 https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=co.elastic.otel&a=elastic-otel-javaagent&v=LATEST /app/opentelemetry-javaagent.jar
COPY --from=intermediate /opentelemetry-javaagent.jar /usr/src/app/opentelemetry-javaagent.jar

ENV JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar
ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true
ENV ELASTIC_OTEL_SPAN_STACK_TRACE_MIN_DURATION=2
Expand Down
Loading