Skip to content

Commit 3e3354b

Browse files
authored
additional build files support (#115)
1 parent e980019 commit 3e3354b

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

imagetool/src/main/java/com/oracle/weblogic/imagetool/api/model/CachedFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public Path copyFile(CacheStore cacheStore, String buildContextDir) throws IOExc
9797
logger.entering();
9898
Path result = null;
9999
String sourceFile = resolve(cacheStore);
100-
logger.info("copying {0} to build context folder.", sourceFile);
100+
logger.info("IMG-0043", sourceFile);
101101
String targetFilename = new File(sourceFile).getName();
102102
try {
103103
result = Files.copy(Paths.get(sourceFile), Paths.get(buildContextDir, targetFilename));

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ private void handleAdditionalBuildCommands() throws IOException {
7171
AdditionalBuildCommands additionalBuildCommands = AdditionalBuildCommands.load(additionalBuildCommandsPath);
7272
dockerfileOptions.setAdditionalBuildCommands(additionalBuildCommands.getContents());
7373
}
74+
75+
if (additionalBuildFiles != null) {
76+
for (Path additionalFile : additionalBuildFiles) {
77+
if (!Files.isRegularFile(additionalFile)) {
78+
throw new FileNotFoundException(Utils.getMessage("IMG-0030", additionalFile));
79+
}
80+
Path targetFile = Paths.get(getTempDirectory(), additionalFile.getFileName().toString());
81+
logger.info("IMG-0043", additionalFile);
82+
Utils.copyLocalFile(additionalFile.toString(), targetFile.toString(), false);
83+
}
84+
}
7485
}
7586

7687
void runDockerCommand(String dockerfile, List<String> command) throws IOException, InterruptedException {
@@ -242,7 +253,7 @@ List<String> handlePatchFiles(String previousInventory) throws Exception {
242253
}
243254

244255
private Path createPatchesTempDirectory() throws IOException {
245-
Path tmpPatchesDir = Files.createDirectory(Paths.get(tempDirectory, "patches"));
256+
Path tmpPatchesDir = Files.createDirectory(Paths.get(getTempDirectory(), "patches"));
246257
Files.createFile(Paths.get(tmpPatchesDir.toAbsolutePath().toString(), "dummy.txt"));
247258
return tmpPatchesDir;
248259
}
@@ -358,6 +369,12 @@ String getPassword() {
358369
)
359370
private Path additionalBuildCommandsPath;
360371

372+
@Option(
373+
names = {"--additionalBuildFiles"},
374+
description = "comma separated list of files that should be copied to the build context folder"
375+
)
376+
private List<Path> additionalBuildFiles;
377+
361378
@Option(
362379
names = {"--dryRun"},
363380
description = "Skip Docker build execution and print Dockerfile to stdout"

imagetool/src/main/resources/ImageTool.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ IMG-0039=Using middleware installers ({0}) version {1}
4141
IMG-0040=When providing custom response files, a response file must be provided for each of the installers {0}. Found {1}, expected {2}.
4242
IMG-0041=Using provided installer response file: {0} for {1} install
4343
IMG-0042={0} was not found or is not a regular file
44+
IMG-0043=copying {0} to build context folder.

site/create-image.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Usage: imagetool create [OPTIONS]
88

99
| Parameter | Definition | Default |
1010
| --- | --- | --- |
11-
|`--additionalBuildCommands`| Path to a file with additional build commands. For more details, see [Additional information](#additional-information). |
12-
|`--chown` | `userid:groupid` for JDK/Middleware installs and patches. | `oracle:oracle` |
11+
| `--additionalBuildCommands` | Path to a file with additional build commands. For more details, see [Additional information](#additional-information). |
12+
| `--additionalBuildFiles` | Additional files that are required by your `additionalBuildCommands`. A comma separated list of files that should be copied to the build context. |
13+
| `--chown` | `userid:groupid` for JDK/Middleware installs and patches. | `oracle:oracle` |
1314
| `--docker` | Path to the Docker executable. | `docker` |
1415
| `--dryRun` | Skip Docker build execution and print the Dockerfile to stdout. | |
1516
| `--fromImage` | Docker image to use as a base image when creating a new image. | `oraclelinux:7-slim` |

site/rebase-image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Usage: imagetool rebase [OPTIONS]
1111
| Parameter | Definition | Default |
1212
| --- | --- | --- |
1313
| `--additionalBuildCommands` | Path to a file with additional build commands. For more details, see [Additional information](#additional-information). |
14+
| `--additionalBuildFiles` | Additional files that are required by your `additionalBuildCommands`. A comma separated list of files that should be copied to the build context. |
1415
| `--chown` | `userid:groupid` for JDK/Middleware installs and patches. | `oracle:oracle` |
1516
| `--docker` | Path to the Docker executable. | `docker` |
1617
| `--dryRun` | Skip Docker build execution and print the Dockerfile to stdout. | |

site/update-image.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Update WebLogic Docker image with selected patches
2323
```
2424
| Parameter | Definition | Default |
2525
| --- | --- | --- |
26-
|`--additionalBuildCommands`| Path to a file with additional build commands. For more details, see [Additional information](#additional-information). |
27-
|`--chown` | `userid:groupid` for JDK/Middleware installs and patches. | `oracle:oracle` |
26+
| `--additionalBuildCommands` | Path to a file with additional build commands. For more details, see [Additional information](#additional-information). |
27+
| `--additionalBuildFiles` | Additional files that are required by your `additionalBuildCommands`. A comma separated list of files that should be copied to the build context. |
28+
| `--chown` | `userid:groupid` for JDK/Middleware installs and patches. | `oracle:oracle` |
2829
| `--docker` | Path to the Docker executable. | `docker` |
2930
| `--dryRun` | Skip Docker build execution and print the Dockerfile to stdout. | |
3031
| `--fromImage` | Docker image to be updated. The `fromImage` option serves as a starting point for the new image to be created. | `weblogic:12.2.1.3.0` |

0 commit comments

Comments
 (0)