Skip to content

Commit

Permalink
Configure DOCKER_HOST env var too
Browse files Browse the repository at this point in the history
Signed-off-by: cmoulliard <[email protected]>
  • Loading branch information
cmoulliard committed Nov 21, 2024
1 parent acb859c commit 9761521
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions samples/build-me/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
16 changes: 11 additions & 5 deletions samples/build-me/src/main/java/dev/snowdrop/BuildMe.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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<String, String> 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<String, String> 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()
Expand All @@ -45,6 +50,7 @@ public static void main(String... args) {
.endPlatformConfig()
.withNewDockerConfig()
.withDockerClient(client)
.withDockerHost(DOCKER_HOST)
.endDockerConfig()
.withNewLogConfig()
.withLogger(new SystemLogger())
Expand Down

0 comments on commit 9761521

Please sign in to comment.