Skip to content

Commit e5bf846

Browse files
committed
Update NativeAdvancedImageFromDockerfile.java
1 parent 5cdb47c commit e5bf846

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎testcontainers-advanced-imagebuilder/src/main/java/software/xdev/testcontainers/imagebuilder/buildxnative/NativeAdvancedImageFromDockerfile.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@
7070
public class NativeAdvancedImageFromDockerfile
7171
extends AbstractImageFromDockerfile<NativeAdvancedImageFromDockerfile>
7272
{
73-
protected List<String> baseCommand = List.of("docker", "build");
73+
protected List<String> baseCommand = List.of("docker", "buildx", "build");
7474
protected List<String> additionalArgs = new ArrayList<>();
7575
protected Optional<String> optCacheFrom = Optional.empty();
7676
protected Optional<String> optCacheTo = Optional.empty();
77+
protected boolean load = true;
7778

7879
protected Duration timeout = Duration.ofMinutes(5);
7980

@@ -108,12 +109,18 @@ protected List<String> buildCommand(final Optional<String> optDockerFilePath)
108109
.filter(Optional::isPresent)
109110
.mapToInt(o -> 2)
110111
.sum()
112+
+ (this.load ? 1 : 0)
111113
);
112114

113115
commandArgs.addAll(this.baseCommand);
114116

115117
this.addCommandArg(optDockerFilePath, "-f", commandArgs);
116118

119+
if(this.load)
120+
{
121+
commandArgs.add("--load");
122+
}
123+
117124
this.addCommandArg(this.optTarget, "--target", commandArgs);
118125
this.addCommandArg(this.optCacheFrom, "--cache-from", commandArgs);
119126
this.addCommandArg(this.optCacheTo, "--cache-to", commandArgs);
@@ -310,5 +317,11 @@ public NativeAdvancedImageFromDockerfile withCacheTo(final String cacheTo)
310317
return this;
311318
}
312319

320+
public NativeAdvancedImageFromDockerfile withLoad(final boolean load)
321+
{
322+
this.load = load;
323+
return this;
324+
}
325+
313326
// endregion
314327
}

0 commit comments

Comments
 (0)