Skip to content

Commit

Permalink
[java] Fix buildpack lib-injection image (#3542)
Browse files Browse the repository at this point in the history
Co-authored-by: iamluc <[email protected]>
  • Loading branch information
randomanderson and iamluc authored Dec 12, 2024
1 parent fd3c46c commit fd8766c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
import software.amazon.awssdk.services.ecr.EcrClient
import software.amazon.awssdk.services.ecr.model.AuthorizationData
import java.util.Base64

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(platform("software.amazon.awssdk:bom:2.20.121"))
classpath("software.amazon.awssdk:ecr")
classpath("software.amazon.awssdk:sts") // sts is required to use roleArn in aws profiles
}
}

plugins {
id("org.springframework.boot") version "2.7.2"
Expand Down Expand Up @@ -31,23 +45,33 @@ tasks.withType<Test> {
val dockerImageRepo: String? by project
val resolvedDockerImageRepo: String = dockerImageRepo ?: "docker.io/" + System.getenv("DOCKER_USERNAME") + "/dd-lib-java-init-test-app"
val dockerImageTag: String by project
val useDockerProxy: String? by project

tasks.named<BootBuildImage>("bootBuildImage") {
val arch = System.getProperty("os.arch")
imageName = "${resolvedDockerImageRepo}:${dockerImageTag}"
//if (arch == "aarch64"){
// builder = "dashaun/builder:tiny"
// environment.set("BP_DATADOG_ENABLED","true")
//}

//TODO Change to use images from gcr.io to aboud docker hub rate limits
//There is a bug: https://github.com/paketo-buildpacks/adoptium/issues/401
//buildpacks = listOf(
// "gcr.io/paketo-buildpacks/adoptium:latest",
// "urn:cnb:builder:paketo-buildpacks/java"
//"urn:cnb:builder:paketo-buildpacks/java",
//"gcr.io/paketo-buildpacks/new-relic",
//"gcr.io/paketo-buildpacks/builder:base",
//"gcr.io/paketo-buildpacks/run:base-cnb",
//"gcr.io/paketo-buildpacks/adoptium:11.2.3"
//)

if (useDockerProxy == null) {
builder = "paketobuildpacks/builder-jammy-java-tiny:0.0.11"
runImage = "paketobuildpacks/run-jammy-tiny:0.2.55"
} else {
// Use dockerhub mirror
builder = "669783387624.dkr.ecr.us-east-1.amazonaws.com/dockerhub/paketobuildpacks/builder-jammy-java-tiny:0.0.11"
runImage = "669783387624.dkr.ecr.us-east-1.amazonaws.com/dockerhub/paketobuildpacks/run-jammy-tiny:0.2.55"

// Setup authentication
// https://stackoverflow.com/questions/65320552/publish-docker-images-using-spring-boot-plugin-without-credentials/76898025#76898025
val ecrClient = EcrClient.builder().build()
val base64Token = ecrClient
.getAuthorizationToken()
.authorizationData()[0]
.authorizationToken()
val auth = String(Base64.getDecoder().decode(base64Token)).split(":")

docker {
builderRegistry {
username = auth[0]
password = auth[1]
}
}
}
}
3 changes: 0 additions & 3 deletions tests/auto_inject/test_auto_inject_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def test_profiling(self, virtual_machine):
@features.container_auto_installation_script
@scenarios.container_auto_injection_install_script
class TestContainerAutoInjectInstallScript(base.AutoInjectBaseTest):
@flaky(weblog_variant="test-app-java-buildpack", reason="APMON-1595")
@parametrize_virtual_machines(
bugs=[{"vm_name": "AlmaLinux_8_arm64", "weblog_variant": "test-app-python-alpine", "reason": "APMON-1576"}]
)
Expand Down Expand Up @@ -146,7 +145,6 @@ class TestInstallerAutoInjectManual(base.AutoInjectBaseTest):
# Note: uninstallation of a single installer package is not available today
#  on the installer. As we can't only uninstall the injector, we are skipping
#  the uninstall test today
@flaky(weblog_variant="test-app-java-buildpack", reason="APMON-1595")
@parametrize_virtual_machines(
bugs=[
{"vm_name": "AlmaLinux_8_arm64", "weblog_variant": "test-app-python-alpine", "reason": "APMON-1576"},
Expand All @@ -167,7 +165,6 @@ def test_install_uninstall(self, virtual_machine):
@features.installer_auto_instrumentation
@scenarios.simple_installer_auto_injection
class TestSimpleInstallerAutoInjectManual(base.AutoInjectBaseTest):
@flaky(weblog_variant="test-app-java-buildpack", reason="APMON-1595")
@parametrize_virtual_machines(
bugs=[
{"vm_name": "AlmaLinux_8_arm64", "weblog_variant": "test-app-python-alpine", "reason": "APMON-1576"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ weblog:
local_path: utils/build/virtual_machine/weblogs/java/test-app-java-buildpack/test-app-java_docker_compose_run_buildpack.sh

- name: copy-docker-compose-file
local_path: utils/build/virtual_machine/weblogs/java/test-app-java-container/docker-compose.yml
local_path: utils/build/virtual_machine/weblogs/common/docker-compose.yml

- name: copy-java-app
local_path: lib-injection/build/docker/java/dd-lib-java-init-test-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ sudo chmod -R 755 *

rm -rf Dockerfile || true

sudo systemctl start docker # Start docker service if it's not started

echo "**************** Docker system df *****************"
sudo docker system df
echo "**************** Disk usage *****************"
Expand All @@ -19,11 +21,11 @@ sudo docker images
echo "**************** Docker containers *****************"
sudo docker ps -a
echo "**************** Docker volumes *****************"
sudo docker volume ls
sudo docker volume ls

echo "**************** BUILDING BUILDPACK *****************"
sudo ./gradlew build
sudo ./gradlew -PdockerImageRepo=system-tests/local -PdockerImageTag=latest clean bootBuildImage
sudo ./gradlew -PdockerImageRepo=system-tests/local -PdockerImageTag=latest -PuseDockerProxy=true clean bootBuildImage

echo "**************** RUN SERVICES*****************"
if [ -f docker-compose-agent-prod.yml ]; then
Expand Down

0 comments on commit fd8766c

Please sign in to comment.