Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ If you plan to push your image to a registry, then set your registry credential
```bash
export REGISTRY_USERNAME="<REGISTRY_USERNAME>"
export REGISTRY_PASSWORD="<REGISTRY_PASSWORD>"
export REGISTRY_SERVER="docker.io"
export REGISTRY_ADDRESS="docker.io"
```

Execute this command in a terminal:
Expand Down
4 changes: 3 additions & 1 deletion samples/build-me/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ target/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

.env
7 changes: 6 additions & 1 deletion samples/build-me/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ If you plan to push your image to a registry, then set your registry credential
```bash
export REGISTRY_USERNAME="<REGISTRY_USERNAME>"
export REGISTRY_PASSWORD="<REGISTRY_PASSWORD>"
export REGISTRY_SERVER="docker.io"
export REGISTRY_ADDRESS="docker.io"
```

If you prefer that lifecycle don't access the mounted docker socket but talk directly with the container registry to build the image, then set to `false` the following variable:
```shell
export USE_DAEMON=false
```

Execute this command in a terminal:
Expand Down
2 changes: 1 addition & 1 deletion samples/build-me/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>dev.snowdrop</groupId>
<artifactId>buildpack-client</artifactId>
<version>0.0.12</version>
<version>0.0.14</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
22 changes: 9 additions & 13 deletions samples/build-me/src/main/java/dev/snowdrop/BuildMe.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package dev.snowdrop;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

import dev.snowdrop.buildpack.*;
import dev.snowdrop.buildpack.config.*;
import dev.snowdrop.buildpack.docker.*;
import dev.snowdrop.buildpack.utils.OperatingSytem;

import static dev.snowdrop.buildpack.docker.DockerClientUtils.getDockerClient;

public class BuildMe {

Expand All @@ -21,11 +16,12 @@ public static void main(String... args) {
System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");

String REGISTRY_USERNAME = System.getenv("REGISTRY_USERNAME");
String REGISTRY_PASSWORD = System.getenv("REGISTRY_PASSWORD");
String REGISTRY_SERVER = System.getenv("REGISTRY_SERVER");
String IMAGE_REF = System.getenv("IMAGE_REF");
String PROJECT_PATH = System.getenv("PROJECT_PATH");
String IMAGE_REF = Optional.ofNullable(System.getenv("IMAGE_REF"))
.orElseThrow(() -> new IllegalStateException("Missing env var: IMAGE_REF"));
String PROJECT_PATH = Optional.ofNullable(System.getenv("PROJECT_PATH"))
.orElseThrow(() -> new IllegalStateException("Missing env var: PROJECT_PATH"));
String USE_DAEMON = Optional.ofNullable(System.getenv("USE_DAEMON"))
.orElse("true");

Map<String, String> envMap = System.getenv().entrySet().stream()
.filter(entry -> entry.getKey().startsWith("BP_") || entry.getKey().startsWith("CNB_"))
Expand All @@ -38,7 +34,7 @@ public static void main(String... args) {

List<RegistryAuthConfig> authInfo = new ArrayList<>();
if(System.getenv("REGISTRY_ADDRESS")!=null){
String registry = System.getenv("REGISTRY_SERVER");
String registry = System.getenv("REGISTRY_ADDRESS");
String username = System.getenv("REGISTRY_USER");
String password = System.getenv("REGISTRY_PASS");
RegistryAuthConfig authConfig = RegistryAuthConfig.builder()
Expand All @@ -57,7 +53,7 @@ public static void main(String... args) {
.endPlatformConfig()
.withNewDockerConfig()
.withAuthConfigs(authInfo)
.withUseDaemon(false)
.withUseDaemon(Boolean.parseBoolean(USE_DAEMON))
.endDockerConfig()
.withNewLogConfig()
.withLogger(new SystemLogger())
Expand Down