Skip to content

Commit 44a1ada

Browse files
committed
Merge branch 'buildx-force-rm' into 'main'
Remove force-rm default from buildx and add command line option for buildx See merge request weblogic-cloud/weblogic-image-tool!495
2 parents 18d83cf + c5af585 commit 44a1ada

File tree

9 files changed

+73
-26
lines changed

9 files changed

+73
-26
lines changed

bug_release.sh

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# Only use this script when releasing bug fixes (removes SNAPSHOT for version)
3+
git checkout main
24

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

1113
echo New Version: ${new_version}
1214

13-
echo mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
14-
echo mvn clean install
15-
echo git add .
16-
echo git commit -m \"release ${project_version_number_only}\"
17-
echo git push
15+
mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
16+
mvn clean install
17+
git add .
18+
git commit -m \"release ${project_version_number_only}\"
19+
git push
1820

19-
echo git tag release-${project_version_number_only}
20-
echo git push origin release-${project_version_number_only}
21+
git tag release-${project_version_number_only}
22+
git push origin release-${project_version_number_only}
2123

22-
echo mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
23-
echo mvn clean install
24-
echo git add .
25-
echo git commit -m \"preparing for next development iteration\"
26-
echo git push
24+
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
25+
mvn clean install
26+
git add .
27+
git commit -m \"preparing for next development iteration\"
28+
git push
2729

documentation/site/content/userguide/tools/create-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Usage: imagetool create [OPTIONS]
4848
| `--strictPatchOrdering` | Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). | |
4949
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
5050
| `--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` |
51+
| `--useBuildx` | Use BuildKit for building the container image. | |
5152
| `--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`. | |
5253
| `--version` | Installer version. | `12.2.1.3.0` |
5354
| `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files. | |

documentation/site/content/userguide/tools/rebase-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Usage: imagetool rebase [OPTIONS]
4747
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
4848
| `--targetImage` | Container image to extend for the domain's new image. | |
4949
| `--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` |
50+
| `--useBuildx` | Use BuildKit for building the container image. | |
5051
| `--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`. | |
5152
| `--version` | Installer version. | `12.2.1.3.0` |
5253

documentation/site/content/userguide/tools/update-image.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Update WebLogic Docker image with selected patches
4949
| `--strictPatchOrdering` | Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). | |
5050
| `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
5151
| `--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` |
52+
| `--useBuildx` | Use BuildKit for building the container image. | |
5253
| `--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`. | |
5354
| `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files. | |
5455
| `--wdtDomainHome` | Path to the `-domain_home` for WDT. | `/u01/domains/base_domain` |

imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public BuildCommand tag(String value) {
6060
return this;
6161
}
6262

63+
/**
64+
* Toggle the use of the BuildKit.
65+
* If true, the build command will start "buildx build".
66+
* If false, the build command will start "build".
67+
* @param value true to enable buildx
68+
* @return this
69+
*/
70+
public BuildCommand useBuildx(boolean value) {
71+
useBuildx = value;
72+
return this;
73+
}
74+
6375
/**
6476
* Add container build platform. Pass the desired
6577
* build architecture to the build process.
@@ -72,7 +84,7 @@ public BuildCommand platform(String value) {
7284
}
7385
command.add("--platform");
7486
command.add(value);
75-
useBuildx = true;
87+
useBuildx(true);
7688
return this;
7789
}
7890

@@ -83,7 +95,8 @@ public BuildCommand platform(String value) {
8395
* @return this
8496
*/
8597
public BuildCommand forceRm(boolean value) {
86-
if (value) {
98+
// Docker removed --force-rm from the buildx build API, and Podman defaults --force-rm=true
99+
if (value && !useBuildx) {
87100
command.add("--force-rm");
88101
}
89102
return this;

imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ BuildCommand getInitialBuildCmd(String contextFolder) {
121121
logger.entering();
122122
BuildCommand cmdBuilder = new BuildCommand(buildEngine, contextFolder);
123123

124-
cmdBuilder.forceRm(!skipcleanup)
125-
.tag(imageTag)
124+
cmdBuilder.tag(imageTag)
125+
.useBuildx(useBuildx)
126126
.platform(buildPlatform)
127+
.forceRm(!skipcleanup)
127128
.network(buildNetwork)
128129
.pull(buildPull)
129130
.additionalOptions(buildOptions)
@@ -450,6 +451,12 @@ public Architecture getTargetArchitecture() {
450451
)
451452
private String buildPlatform;
452453

454+
@Option(
455+
names = {"--useBuildx"},
456+
description = "Use the BuildKit for building the container image (default when building multi-architecture)"
457+
)
458+
private boolean useBuildx;
459+
453460
@Parameters(
454461
description = "Container build options.",
455462
hidden = true

imagetool/src/test/java/com/oracle/weblogic/imagetool/builder/BuilderTest.java

+21
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,25 @@ void testBuildWithProxyPass() {
7979
cmd.tag("img:3").buildArg("http_proxy", "http://user:pass@blah/blah", true);
8080
assertEquals(expected("--tag img:3 --build-arg http_proxy=********"), cmd.toString());
8181
}
82+
83+
@Test
84+
void testBuildArgsWithPlatform() {
85+
Map<String,String> argMap = null;
86+
87+
BuildCommand cmd = new BuildCommand(BUILD_ENGINE, BUILD_CONTEXT)
88+
.tag("img:4")
89+
.pull(true)
90+
.platform("linux/amd64")
91+
.forceRm(true)
92+
.network("private-net")
93+
.buildArg(argMap);
94+
95+
// expect that "--force-rm" will not be used, expect "buildx build" will be used
96+
assertEquals(
97+
String.format("%s buildx build %s %s",
98+
BUILD_ENGINE,
99+
"--tag img:4 --pull --platform linux/amd64 --network private-net",
100+
BUILD_CONTEXT),
101+
cmd.toString());
102+
}
82103
}

pom.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<dependency>
7373
<groupId>org.junit.jupiter</groupId>
7474
<artifactId>junit-jupiter-engine</artifactId>
75-
<version>5.11.3</version>
75+
<version>5.11.4</version>
7676
<scope>test</scope>
7777
</dependency>
7878
<dependency>
@@ -154,7 +154,7 @@
154154
<plugin>
155155
<groupId>org.apache.maven.plugins</groupId>
156156
<artifactId>maven-failsafe-plugin</artifactId>
157-
<version>3.5.0</version>
157+
<version>3.5.2</version>
158158
<configuration>
159159
<groups>${test.groups}</groups>
160160
<excludedGroups>failing</excludedGroups>
@@ -214,7 +214,7 @@
214214
<plugin>
215215
<groupId>org.apache.maven.plugins</groupId>
216216
<artifactId>maven-checkstyle-plugin</artifactId>
217-
<version>3.5.0</version>
217+
<version>3.6.0</version>
218218
<executions>
219219
<execution>
220220
<id>checkstyle</id>
@@ -242,14 +242,14 @@
242242
<dependency>
243243
<groupId>com.puppycrawl.tools</groupId>
244244
<artifactId>checkstyle</artifactId>
245-
<version>10.20.2</version>
245+
<version>10.21.1</version>
246246
</dependency>
247247
</dependencies>
248248
</plugin>
249249
<plugin>
250250
<groupId>org.apache.maven.plugins</groupId>
251251
<artifactId>maven-surefire-plugin</artifactId>
252-
<version>3.5.1</version>
252+
<version>3.5.2</version>
253253
<configuration>
254254
<groups>unit</groups>
255255
<excludedGroups>failing</excludedGroups>

tests/src/test/java/com/oracle/weblogic/imagetool/tests/utils/Runner.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ public static CommandResult run(String command, PrintWriter output) throws IOExc
6868

6969
p = pb.start();
7070

71-
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
7271
StringBuilder processOut = new StringBuilder();
73-
String line;
74-
while ((line = reader.readLine()) != null) {
75-
processOut.append(line);
76-
output.println(line);
72+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) {
73+
String line;
74+
while ((line = reader.readLine()) != null) {
75+
processOut.append(line);
76+
output.println(line);
77+
}
7778
}
7879

7980
p.waitFor();

0 commit comments

Comments
 (0)