Skip to content

Commit

Permalink
Allow users to specify arbitrary arguments to docker build
Browse files Browse the repository at this point in the history
Closes: #33866
  • Loading branch information
geoand committed Jun 7, 2023
1 parent f3bbc25 commit b84e68e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public class DockerConfig {
@ConfigItem
public Optional<String> executableName;

/**
* Additional arbitrary arguments passed to the executable when building the container image.
*/
@ConfigItem
public Optional<List<String>> additionalArgs;

/**
* Configuration for Docker Buildx options
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ private void loginToRegistryIfNeeded(ContainerImageConfig containerImageConfig,

private String[] getDockerArgs(String image, DockerfilePaths dockerfilePaths, ContainerImageConfig containerImageConfig,
DockerConfig dockerConfig, ContainerImageInfoBuildItem containerImageInfo, boolean pushImages) {
List<String> dockerArgs = new ArrayList<>(6 + dockerConfig.buildArgs.size());
List<String> dockerArgs = new ArrayList<>(6 + dockerConfig.buildArgs.size() + dockerConfig.additionalArgs.map(
List::size).orElse(0));
boolean useBuildx = dockerConfig.buildx.useBuildx();

if (useBuildx) {
Expand Down Expand Up @@ -303,6 +304,7 @@ private String[] getDockerArgs(String image, DockerfilePaths dockerfilePaths, Co
dockerArgs.add("--network");
dockerArgs.add(network);
});
dockerConfig.additionalArgs.ifPresent(dockerArgs::addAll);
dockerArgs.addAll(Arrays.asList("-t", image));

if (useBuildx) {
Expand Down

0 comments on commit b84e68e

Please sign in to comment.