Skip to content

Commit

Permalink
Remove force-rm default from buildx and add command line option for b…
Browse files Browse the repository at this point in the history
…uildx
  • Loading branch information
ddsharpe committed Jan 7, 2025
1 parent 18d83cf commit c5af585
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 26 deletions.
26 changes: 14 additions & 12 deletions bug_release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Only use this script when releasing bug fixes (removes SNAPSHOT for version)
git checkout main

project_version=$(mvn help:evaluate -q -DforceStdout -D"expression=project.version")
echo Current POM version: ${project_version}
Expand All @@ -10,18 +12,18 @@ new_version=$(echo $project_version | sed -e "s/[0-9][0-9]*\([^0-9]*\)$/$next_di

echo New Version: ${new_version}

echo mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
echo mvn clean install
echo git add .
echo git commit -m \"release ${project_version_number_only}\"
echo git push
mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
mvn clean install
git add .
git commit -m \"release ${project_version_number_only}\"
git push

echo git tag release-${project_version_number_only}
echo git push origin release-${project_version_number_only}
git tag release-${project_version_number_only}
git push origin release-${project_version_number_only}

echo mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
echo mvn clean install
echo git add .
echo git commit -m \"preparing for next development iteration\"
echo git push
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
mvn clean install
git add .
git commit -m \"preparing for next development iteration\"
git push

1 change: 1 addition & 0 deletions documentation/site/content/userguide/tools/create-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Usage: imagetool create [OPTIONS]
| `--strictPatchOrdering` | Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). | |
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
| `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS` | `WLS` |
| `--useBuildx` | Use BuildKit for building the container image. | |
| `--user` | Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`. | |
| `--version` | Installer version. | `12.2.1.3.0` |
| `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files. | |
Expand Down
1 change: 1 addition & 0 deletions documentation/site/content/userguide/tools/rebase-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Usage: imagetool rebase [OPTIONS]
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
| `--targetImage` | Container image to extend for the domain's new image. | |
| `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS` | `WLS` |
| `--useBuildx` | Use BuildKit for building the container image. | |
| `--user` | Your Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`. | |
| `--version` | Installer version. | `12.2.1.3.0` |

Expand Down
1 change: 1 addition & 0 deletions documentation/site/content/userguide/tools/update-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Update WebLogic Docker image with selected patches
| `--strictPatchOrdering` | Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). | |
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
| `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS` | `WLS` |
| `--useBuildx` | Use BuildKit for building the container image. | |
| `--user` | Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`. | |
| `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files. | |
| `--wdtDomainHome` | Path to the `-domain_home` for WDT. | `/u01/domains/base_domain` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ public BuildCommand tag(String value) {
return this;
}

/**
* Toggle the use of the BuildKit.
* If true, the build command will start "buildx build".
* If false, the build command will start "build".
* @param value true to enable buildx
* @return this
*/
public BuildCommand useBuildx(boolean value) {
useBuildx = value;
return this;
}

/**
* Add container build platform. Pass the desired
* build architecture to the build process.
Expand All @@ -72,7 +84,7 @@ public BuildCommand platform(String value) {
}
command.add("--platform");
command.add(value);
useBuildx = true;
useBuildx(true);
return this;
}

Expand All @@ -83,7 +95,8 @@ public BuildCommand platform(String value) {
* @return this
*/
public BuildCommand forceRm(boolean value) {
if (value) {
// Docker removed --force-rm from the buildx build API, and Podman defaults --force-rm=true
if (value && !useBuildx) {
command.add("--force-rm");
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ BuildCommand getInitialBuildCmd(String contextFolder) {
logger.entering();
BuildCommand cmdBuilder = new BuildCommand(buildEngine, contextFolder);

cmdBuilder.forceRm(!skipcleanup)
.tag(imageTag)
cmdBuilder.tag(imageTag)
.useBuildx(useBuildx)
.platform(buildPlatform)
.forceRm(!skipcleanup)
.network(buildNetwork)
.pull(buildPull)
.additionalOptions(buildOptions)
Expand Down Expand Up @@ -450,6 +451,12 @@ public Architecture getTargetArchitecture() {
)
private String buildPlatform;

@Option(
names = {"--useBuildx"},
description = "Use the BuildKit for building the container image (default when building multi-architecture)"
)
private boolean useBuildx;

@Parameters(
description = "Container build options.",
hidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,25 @@ void testBuildWithProxyPass() {
cmd.tag("img:3").buildArg("http_proxy", "http://user:pass@blah/blah", true);
assertEquals(expected("--tag img:3 --build-arg http_proxy=********"), cmd.toString());
}

@Test
void testBuildArgsWithPlatform() {
Map<String,String> argMap = null;

BuildCommand cmd = new BuildCommand(BUILD_ENGINE, BUILD_CONTEXT)
.tag("img:4")
.pull(true)
.platform("linux/amd64")
.forceRm(true)
.network("private-net")
.buildArg(argMap);

// expect that "--force-rm" will not be used, expect "buildx build" will be used
assertEquals(
String.format("%s buildx build %s %s",
BUILD_ENGINE,
"--tag img:4 --pull --platform linux/amd64 --network private-net",
BUILD_CONTEXT),
cmd.toString());
}
}
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.3</version>
<version>5.11.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -154,7 +154,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.2</version>
<configuration>
<groups>${test.groups}</groups>
<excludedGroups>failing</excludedGroups>
Expand Down Expand Up @@ -214,7 +214,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<executions>
<execution>
<id>checkstyle</id>
Expand Down Expand Up @@ -242,14 +242,14 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.20.2</version>
<version>10.21.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.1</version>
<version>3.5.2</version>
<configuration>
<groups>unit</groups>
<excludedGroups>failing</excludedGroups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ public static CommandResult run(String command, PrintWriter output) throws IOExc

p = pb.start();

BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
StringBuilder processOut = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
processOut.append(line);
output.println(line);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
processOut.append(line);
output.println(line);
}
}

p.waitFor();
Expand Down

0 comments on commit c5af585

Please sign in to comment.