diff --git a/.github/README.md b/.github/README.md index 134f0ab877..e151cf3001 100644 --- a/.github/README.md +++ b/.github/README.md @@ -3,7 +3,7 @@ The following guide describes how to setup the OpenTelemetry demo with Elastic Observability using [Docker compose](#docker-compose) or [Kubernetes](#kubernetes). This fork introduces several changes to the agents used in the demo: -- The Java agent within the [Ad](../src/adservice/Dockerfile#L27) and [Fraud Detection](../src/frauddetectionservice/Dockerfile#L21) services have been replaced with the Elastic distribution of the OpenTelemetry Java Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-distribution-opentelemetry-java-agent). +- The Java agent within the [Ad](../src/adservice/Dockerfile.elastic) and [Fraud Detection](../src/frauddetectionservice/Dockerfile.elastic) services have been replaced with the Elastic distribution of the OpenTelemetry Java Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-distribution-opentelemetry-java-agent). ## Docker compose diff --git a/src/adservice/Dockerfile.elastic b/src/adservice/Dockerfile.elastic new file mode 100644 index 0000000000..52e6ded50f --- /dev/null +++ b/src/adservice/Dockerfile.elastic @@ -0,0 +1,28 @@ +FROM eclipse-temurin:21-jdk as builder + +WORKDIR /usr/src/app/ + +COPY ./src/adservice/gradlew* ./src/adservice/settings.gradle* ./src/adservice/build.gradle ./ +COPY ./src/adservice/gradle ./gradle + +RUN ./gradlew +RUN ./gradlew downloadRepos + +COPY ./src/adservice/ ./ +COPY ./pb/ ./proto +RUN ./gradlew installDist -PprotoSourceDir=./proto + +# ----------------------------------------------------------------------------- + +FROM eclipse-temurin:21-jre + +ARG version=0.3.2 +WORKDIR /usr/src/app/ + +COPY --from=builder /usr/src/app/ ./ +ADD --chmod=644 https://repo1.maven.org/maven2/co/elastic/otel/elastic-otel-javaagent/$version/elastic-otel-javaagent-$version.jar /usr/src/app/opentelemetry-javaagent.jar +ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar +ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true + +EXPOSE ${AD_SERVICE_PORT} +ENTRYPOINT [ "./build/install/opentelemetry-demo-ad-service/bin/AdService" ] diff --git a/src/frauddetectionservice/Dockerfile.elastic b/src/frauddetectionservice/Dockerfile.elastic new file mode 100644 index 0000000000..e4f63046b8 --- /dev/null +++ b/src/frauddetectionservice/Dockerfile.elastic @@ -0,0 +1,21 @@ +FROM gradle:8-jdk17 AS builder + +WORKDIR /usr/src/app/ + +COPY ./src/frauddetectionservice/ ./ +COPY ./pb/ ./src/main/proto/ +RUN gradle shadowJar + +# ----------------------------------------------------------------------------- + +FROM gcr.io/distroless/java17-debian11 + +ARG version=0.3.2 +WORKDIR /usr/src/app/ + +COPY --from=builder /usr/src/app/build/libs/frauddetectionservice-1.0-all.jar ./ +ADD --chmod=644 https://repo1.maven.org/maven2/co/elastic/otel/elastic-otel-javaagent/$version/elastic-otel-javaagent-$version.jar /usr/src/app/opentelemetry-javaagent.jar +ENV JAVA_TOOL_OPTIONS=-javaagent:/app/opentelemetry-javaagent.jar +ENV ELASTIC_OTEL_INFERRED_SPANS_ENABLED=true + +ENTRYPOINT [ "java", "-jar", "frauddetectionservice-1.0-all.jar" ]