Skip to content

Commit

Permalink
Updates the trace analytics sample app to run using the latest Spring…
Browse files Browse the repository at this point in the history
… Boot - 3.1.3. Also updates to using JDK 17 which is required, along with moving to the Temurin Docker image as the OpenJDK Docker image is deprecated. (#3343)

Signed-off-by: David Venable <dlv@amazon.com>
  • Loading branch information
dlvenable authored Sep 15, 2023
1 parent b6e38a7 commit c95eb92
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
6 changes: 3 additions & 3 deletions examples/trace-analytics-sample-app/sample-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM gradle:jdk11 as cache
FROM gradle:jdk17 as cache
RUN mkdir -p /home/gradle/cache_home
ENV GRADLE_USER_HOME /home/gradle/cache_home
COPY analytics-service/build.gradle /home/gradle/src/
WORKDIR /home/gradle/src
RUN gradle clean build --daemon

FROM gradle:jdk11 AS build
FROM gradle:jdk17 AS build
COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
COPY analytics-service /home/gradle/src/
WORKDIR /home/gradle/src
RUN gradle bootJar --daemon

RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.0.1/opentelemetry-javaagent-all.jar

FROM openjdk:8-jre-alpine
FROM eclipse-temurin:17-jre-jammy

RUN apk update \
&& apk upgrade \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
FROM gradle:jdk11 as cache
FROM gradle:jdk17 as cache
RUN mkdir -p /home/gradle/cache_home
ENV GRADLE_USER_HOME /home/gradle/cache_home
COPY build.gradle /home/gradle/src/
WORKDIR /home/gradle/src
RUN gradle clean build --daemon

FROM gradle:jdk11 AS build
FROM gradle:jdk17 AS build
COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
COPY . /home/gradle/src/
WORKDIR /home/gradle/src
RUN gradle bootJar --daemon

RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.0.1/opentelemetry-javaagent-all.jar

FROM openjdk:8-jdk-alpine
FROM eclipse-temurin:17-jre-jammy
EXPOSE 8087
RUN mkdir /app
COPY --from=build /home/gradle/src/build/libs/*.jar /app/spring-boot-application.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The app contains two endpoints:
- /metrics

##### Commands to build app and run the JAR:

Building and running this project requires JDK 17 or above.

```
$ ./gradlew clean build
```
Expand All @@ -29,4 +32,16 @@ $ ./gradlew clean build
```
```
$ docker-compose up --build
```
```

#### Sample requests

To verify the application is running, you can provide some sample requests.

```
curl http://localhost:8087/metrics
```

```
curl http://localhost:8087/logs -X POST -H 'Content-Type: application/json' -d '{"service":"analytics", "message":"my message"}'
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@

plugins {
id 'java'
id 'org.springframework.boot' version '2.7.11'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
}


group = 'com.example.restservice'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
mavenCentral()
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.yaml') {
Expand Down

0 comments on commit c95eb92

Please sign in to comment.