Skip to content

Commit

Permalink
[chore] Build and publish application hosted in the repository for th…
Browse files Browse the repository at this point in the history
…e Java instrumentation E2E test (#2094)

* Build and publish the Java E2E image

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

* Fix the tags

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

* Fix the tags

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

* Use reusable workflow

Signed-off-by: Israel Blancas <iblancasa@gmail.com>

---------

Signed-off-by: Israel Blancas <iblancasa@gmail.com>
  • Loading branch information
iblancasa authored Oct 4, 2023
1 parent ad98879 commit 0a86c75
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/publish-autoinstrumentation-e2e-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
with:
language: golang
platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
java:
uses: ./.github/workflows/reusable-publish-autoinstrumentation-e2e-images.yaml
with:
language: java
platforms: linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
apache-httpd:
uses: ./.github/workflows/reusable-publish-autoinstrumentation-e2e-images.yaml
with:
Expand Down
23 changes: 23 additions & 0 deletions tests/instrumentation-e2e-apps/java/DemoApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@SpringBootApplication
public class DemoApplication {

@RequestMapping("/")
String home() {
return "Hello World!";
}

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}

}
23 changes: 23 additions & 0 deletions tests/instrumentation-e2e-apps/java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM --platform=$BUILDPLATFORM eclipse-temurin:17-jdk-focal as builder

RUN apt update
RUN apt install zip unzip -y

RUN mkdir /app

# In some archs, there could be probems setting the executable permissions
RUN mkdir /app/.gradle
RUN chmod -R +x /root/

RUN curl -s "https://get.sdkman.io" | bash
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install springboot && spring init /app"

WORKDIR /app
COPY DemoApplication.java /app/src/main/java/com/example/app/
COPY build.gradle .
RUN ./gradlew bootJar --no-daemon

FROM eclipse-temurin:17.0.8.1_1-jre

COPY --from=builder /app/build/libs/app-0.0.1-SNAPSHOT.jar .
ENTRYPOINT ["java", "-jar", "app-0.0.1-SNAPSHOT.jar"]
25 changes: 25 additions & 0 deletions tests/instrumentation-e2e-apps/java/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-web-test'
}

tasks.named('test') {
useJUnitPlatform()
}

0 comments on commit 0a86c75

Please sign in to comment.