From 976152107aa8a22923de95a830bd13e25be06bde Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Thu, 21 Nov 2024 09:44:38 +0100 Subject: [PATCH] Configure DOCKER_HOST env var too Signed-off-by: cmoulliard --- README.md | 7 +++++++ samples/build-me/README.md | 8 ++++++++ .../src/main/java/dev/snowdrop/BuildMe.java | 16 +++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 61627b0..c863a1c 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,13 @@ Execute this command in a terminal: ```bash mvn compile exec:java ``` +You can also pass the `BP_` or `CNB_` environment variables: +```bash +export BP_JVM_VERSION="21" +export BP_MAVEN_BUILT_ARTIFACT="target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus" +export CNB_LOG_LEVEL=debug +etc +``` ### Jbang diff --git a/samples/build-me/README.md b/samples/build-me/README.md index a2e6e4a..0c2e5f0 100644 --- a/samples/build-me/README.md +++ b/samples/build-me/README.md @@ -28,4 +28,12 @@ export REGISTRY_SERVER="docker.io" Execute this command in a terminal: ```bash mvn compile exec:java +``` + +You can also pass the `BP_` or `CNB_` environment variables: +```bash +export BP_JVM_VERSION="21" +export BP_MAVEN_BUILT_ARTIFACT="target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus" +export CNB_LOG_LEVEL=debug +etc ``` \ No newline at end of file diff --git a/samples/build-me/src/main/java/dev/snowdrop/BuildMe.java b/samples/build-me/src/main/java/dev/snowdrop/BuildMe.java index 3b776a0..ee959fc 100644 --- a/samples/build-me/src/main/java/dev/snowdrop/BuildMe.java +++ b/samples/build-me/src/main/java/dev/snowdrop/BuildMe.java @@ -3,6 +3,7 @@ import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; import com.github.dockerjava.api.DockerClient; import dev.snowdrop.buildpack.*; @@ -24,12 +25,16 @@ public static void main(String... args) { String REGISTRY_SERVER = System.getenv("REGISTRY_SERVER"); String IMAGE_REF = System.getenv("IMAGE_REF"); String PROJECT_PATH = System.getenv("PROJECT_PATH"); + String DOCKER_HOST = System.getenv("DOCKER_HOST"); - Map envMap = new HashMap<>(); - envMap.put("BP_JVM_VERSION", "21"); - envMap.put("CNB_REGISTRY_AUTH",System.getenv("CNB_REGISTRY_AUTH")); - // envMap.put("CNB_LOG_LEVEL","debug"); - // envMap.put("BP_MAVEN_BUILT_ARTIFACT","target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus"); + Map envMap = System.getenv().entrySet().stream() + .filter(entry -> entry.getKey().startsWith("BP_") || entry.getKey().startsWith("CNB_")) + .collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (oldValue, newValue) -> newValue, + HashMap::new + )); DockerClient client = getDockerClient(); client.authConfig() @@ -45,6 +50,7 @@ public static void main(String... args) { .endPlatformConfig() .withNewDockerConfig() .withDockerClient(client) + .withDockerHost(DOCKER_HOST) .endDockerConfig() .withNewLogConfig() .withLogger(new SystemLogger())