Skip to content

Commit 7505852

Browse files
gosurya-oraclejshum2479
authored andcommitted
Java poc
Former-commit-id: 54f66915699a6a5964a1931499b6184e4cbeed76
1 parent f03065a commit 7505852

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+704
-409
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Oracle WebLogic ImageBuilder Tool
2+
3+
Containerization is taking over the software world. In this modern age of software development, Docker and Kubernetes
4+
have become the gold standard. To help customers stay at the forefront of this, Oracle released the
5+
[WebLogic Server Kubernetes Operator](https://github.com/oracle/weblogic-kubernetes-operator). The operator helps
6+
customers move their workloads to the cloud via the kubernetes (cloud neutral) route. It was left to the customers how
7+
to create the docker images and apply patches to these images deployed by the kubernetes operator. To help customers
8+
with this effort, We created the [WebLogic ImageBuilder Tool](https://github.com/oracle/weblogic-imagebuilder-tool).
9+
10+
## Table of Contents
11+
12+
- [Features](#features-of-the-imagebuilder-tool)
13+
- [Create Image](site/create-image.md)
14+
- [Update Image](site/update-image.md)
15+
- [Cache](site/cache.md)
16+
17+
## Features of the Oracle WebLogic ImageBuilder Tool
18+
19+
The tool can create a WebLogic docker image from any base image (ex: oraclelinux, ubuntu), install a given version of
20+
WebLogic (ex: 12.2.1.3.0), install a given jdk (ex: 8u202), apply selected patches and create a domain with a given
21+
version of [WDT](https://github.com/oracle/weblogic-deploy-tooling). The tool can also update a docker image either
22+
created using this tool or a docker image built by the user (should have an ORACLE_HOME env variable defined) by
23+
applying selected patches.
24+
25+
## Prerequisites
26+
27+
- Active internet connection
28+
- The tool needs to communicate with Oracle support system.
29+
- Oracle support credentials
30+
- Oracle support credentials are used to validate and download patches.
31+
- WebLogic and JDK installers from OTN / e-delivery
32+
- WebLogic and JDK installers should be available on local disk.
33+
- Docker client and daemon on the build machine
34+
- Experimental features should be turned on to support docker build --squash option.
35+
36+
## Initialization
37+
38+
Build the project to

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55

66
<modelVersion>4.0.0</modelVersion>
7-
<groupId>oracle.weblogicx.imagebuilder</groupId>
8-
<artifactId>builder</artifactId>
7+
<groupId>oracle.weblogicx</groupId>
8+
<artifactId>imagebuilder</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>

scripts/download-jdk.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

site/cache.md

Whitespace-only changes.

site/create-image.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Create Image
2+
3+
The create command helps build a WebLogic docker image from a given base os image. The required options for the command
4+
are marked with asterisk (*). Password can be provided in one of the three ways.
5+
1) Plain Text
6+
2) Environment Variable
7+
3) File containing the password
8+
9+
```
10+
Missing required options [--tag=TAG, --user=<support email>]
11+
Usage: imagebuilder create [OPTIONS]
12+
Build WebLogic docker image
13+
--docker=<dockerPath> path to docker executable. Default: docker
14+
--fromImage=<fromImage>
15+
Docker image to use as base image.
16+
--httpProxyUrl=<httpProxyUrl>
17+
proxy for http protocol. Ex: http://myproxy:80 or http:
18+
//user:passwd@myproxy:8080
19+
--httpsProxyUrl=<httpsProxyUrl>
20+
proxy for https protocol. Ex: http://myproxy:80 or http:
21+
//user:passwd@myproxy:8080
22+
--jdkVersion=<jdkVersion>
23+
Version of server jdk to install. default: 8u202
24+
--latestPSU Whether to apply patches from latest PSU.
25+
--password=<password for support user id>
26+
Password for support userId
27+
--passwordEnv=<environment variable>
28+
environment variable containing the support password
29+
--passwordFile=<password file>
30+
path to file containing just the password
31+
--patches=patchId[,patchId...]
32+
Comma separated patch Ids. Ex: p12345678,p87654321
33+
* --tag=TAG Tag for the final build image. Ex: store/oracle/weblogic:
34+
12.2.1.3.0
35+
--type=<installerType>
36+
Installer type. default: wls. supported values: wls, fmw
37+
* --user=<support email>
38+
Oracle Support email id
39+
--version=<installerVersion>
40+
Installer version. default: 12.2.1.3.0
41+
--wdtArchive=<wdtArchivePath>
42+
path to wdt archive file used by wdt model
43+
--wdtModel=<wdtModelPath>
44+
path to the wdt model file to create domain with
45+
--wdtVariables=<wdtVariablesPath>
46+
path to wdt variables file used by wdt model
47+
--wdtVersion=<wdtVersion>
48+
wdt version to create the domain
49+
```
50+
51+
## Usage scenarios
52+
53+
**_Note: Use --passwordEnv or --passwordFile instead of --password_**
54+
55+
The commands below assume that all the required jdk, wls or fmw (WebLogic infrastructure installer) have been downloaded
56+
to the cache dir. Use the [cache](cache.md) command to set it up.
57+
58+
- Create an image named sample:wls with WebLogic installer 12.2.1.3.0, server jdk 8u202, latest psu applied.
59+
```
60+
imagebuilder create --tag sample:wls --latestPSU --user [email protected] --password hello
61+
```
62+
63+
- Create an image named sample:wdt with same options as above and create a domain with [WebLogic Deploy Tooling](https://github.com/oracle/weblogic-deploy-tooling)
64+
```
65+
imagebuilder create --tag sample:wdt --latestPSU --user [email protected] --password hello --wdtModel /path/to/model.json --wdtVariables /path/to/variables.json --wdtVersion 0.16
66+
```
67+
If wdtVersion is not provided, the tool uses the latest release.
68+
69+
- Create an image name sample:patch with selected patches applied.
70+
```
71+
imagebuilder create --tag sample:patch --user [email protected] --password hello --patches 12345678,p87654321
72+
```
73+
The patch numbers may or may not start with 'p'.
74+
75+
## Errors
76+
77+
- CachePolicy prohibits download. Please add cache entry for key: jdk_8u202
78+
- This implies that the tool could not find the jdk installer in its cache. Use the [cache](cache.md) command to fix it.
79+
```
80+
imagebuilder cache addInstaller --type jdk --version 8u202 --path /local/path/to/jdk.gz
81+
```

site/update-image.md

Whitespace-only changes.

src/main/java/com/oracle/weblogicx/imagebuilder/api/FileResolver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public interface FileResolver {
77
/**
88
* Given a cache store, check whether the installer / patch file exists on disk.
99
* patch files will be downloaded as required.
10+
*
1011
* @param cacheStore store that keeps track of required artifacts
1112
* @return location of file on disk if found
1213
* @throws Exception in case of error

src/main/java/com/oracle/weblogicx/imagebuilder/api/meta/CacheStore.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ public interface CacheStore {
1515
/**
1616
* Cache dir used by this application. cache dir is where the application downloads
1717
* artifacts to.
18+
*
1819
* @return cache dir location on disk
1920
*/
2021
String getCacheDir();
2122

2223
/**
2324
* Returns the value if key is present. Since the application tracks downloaded artifact location,
2425
* key is usually patch number or artifact identifier. Value is location on disk.
26+
*
2527
* @param key key to look for. Ex: patch number
2628
* @return value if present in cache or else null.
2729
*/
@@ -30,35 +32,40 @@ public interface CacheStore {
3032
/**
3133
* Checks if cache has certain key, value combination. This is used to check if a certain artifact
3234
* is in the desired location if it has been downloaded previously.
33-
* @param key artifact identifier
35+
*
36+
* @param key artifact identifier
3437
* @param value location on disk
3538
* @return true if found
3639
*/
3740
boolean hasMatchingKeyValue(String key, String value);
3841

3942
/**
4043
* Add an entry to the cache metadata file.
41-
* @param key artifact identifier
44+
*
45+
* @param key artifact identifier
4246
* @param value a file path
4347
* @return true if add is successful
4448
*/
4549
boolean addToCache(String key, String value);
4650

4751
/**
4852
* Delete an entry from the cache
53+
*
4954
* @param key key corresponding to an entry in the cache
5055
* @return value or null
5156
*/
5257
String deleteFromCache(String key);
5358

5459
/**
5560
* Returns a map of current items in the cache
61+
*
5662
* @return map of current items
5763
*/
5864
Map<String, String> getCacheItems();
5965

6066
/**
6167
* Set cache directory to new location.
68+
*
6269
* @param value a directory path
6370
* @return true if successful
6471
*/

src/main/java/com/oracle/weblogicx/imagebuilder/api/model/InstallerType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* An enum to represent type of installer
1010
*/
1111
public enum InstallerType {
12-
12+
1313
FMW(WLSInstallerType.FMW.toString()),
1414
JDK("jdk"),
1515
WDT("wdt"),

src/main/java/com/oracle/weblogicx/imagebuilder/cli/CLIDriver.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
package com.oracle.weblogicx.imagebuilder.cli;
22

33
import com.oracle.weblogicx.imagebuilder.api.model.CommandResponse;
4+
import com.oracle.weblogicx.imagebuilder.cli.cache.CacheCLI;
45
import com.oracle.weblogicx.imagebuilder.cli.menu.CreateImage;
56
import com.oracle.weblogicx.imagebuilder.cli.menu.UpdateImage;
6-
import com.oracle.weblogicx.imagebuilder.cli.cache.CacheCLI;
7-
import com.oracle.weblogicx.imagebuilder.util.Constants;
87
import picocli.CommandLine;
98
import picocli.CommandLine.Command;
109
import picocli.CommandLine.HelpCommand;
1110

12-
import java.util.List;
1311
import java.util.concurrent.Callable;
14-
import java.util.stream.Collectors;
15-
import java.util.stream.Stream;
1612

1713
@Command(
1814
name = "imagebuilder",
1915
mixinStandardHelpOptions = true,
2016
description = "%nA tool to build docker images of WebLogic with selected " +
21-
"patches and/or psu(s) applied.%n",
17+
"patches and/or psu(s) applied.%n",
2218
version = "1.0",
2319
sortOptions = false,
2420
subcommands = {
@@ -35,7 +31,7 @@
3531
public class CLIDriver implements Callable<CommandResponse> {
3632

3733
@Override
38-
public CommandResponse call() throws Exception {
34+
public CommandResponse call() {
3935
return null;
4036
}
4137

@@ -44,12 +40,16 @@ public static void main(String[] args) {
4440
if (args.length == 0) {
4541
CommandLine.usage(cliDriver, System.out);
4642
} else {
47-
List<String> argsList = Stream.of(args).collect(Collectors.toList());
48-
argsList.add(Constants.CLI_OPTION);
49-
CommandResponse response = WLSCommandLine.call(cliDriver, argsList.toArray(new String[0]));
43+
//List<String> argsList = Stream.of(args).collect(Collectors.toList());
44+
//argsList.add("--cli");
45+
//CommandResponse response = WLSCommandLine.call(cliDriver, argsList.toArray(new String[0]));
46+
CommandResponse response = WLSCommandLine.call(cliDriver, true, args);
47+
5048
if (response != null) {
5149
System.out.println(String.format("Response code: %d, message: %s", response.getStatus(),
5250
response.getMessage()));
51+
//Map<String, String> results = response.getResult();
52+
//results.forEach((key, value) -> System.out.println(key + "=" + value));
5353
}/* else {
5454
System.out.println("response is null");
5555
}*/

0 commit comments

Comments
 (0)