diff --git a/open-liberty/content.md b/open-liberty/content.md index 48868e905..46c5cba9b 100644 --- a/open-liberty/content.md +++ b/open-liberty/content.md @@ -13,7 +13,7 @@ FROM %%IMAGE%%:kernel COPY server.xml /config/ ``` -The `microProfile1` image contains the features required to implement Eclipse MicroProfile 1.3. The `webProfile8` image contains the features required for Java EE8 Web Profile compliance. The `javaee8` image adds the features required for Java EE8 Full Platform compliance. The `javaee8` image is also tagged with `latest`. The `webProfile7` image contains the features required for Java EE7 Web Profile compliance. The `javaee7` image adds the features required for Java EE7 Full Platform compliance. +The `microProfile1` image contains the features required to implement Eclipse MicroProfile 1.3. The `webProfile8` image contains the features required for Java EE8 Web Profile compliance. The `javaee8` image adds the features required for Java EE8 Full Platform compliance. The `javaee8` image is also tagged with `latest`. The `webProfile7` image contains the features required for Java EE7 Web Profile compliance. The `javaee7` image adds the features required for Java EE7 Full Platform compliance. The `springBoot1` and `springBoot2` images contain the features required for running Spring Boot 1.5 and 2.0 applications. There are also additional images for different JVM combinations. Currently there are tags for java8 only, but there are two variants one based on IBM Java and Ubuntu and the other based on the IBM small footprint Java which is based on alpine linux. The naming structure for the variants is tag-javaversion-vandor/variant. This leads to webProfile8-java8-ibmsfj as one. At this time the full list of images are: @@ -23,6 +23,12 @@ There are also additional images for different JVM combinations. Currently there microProfile1 microProfile1-java8-ibm microProfile1-java8-ibmsfj + springBoot1 + springBoot1-java8-ibm + springBoot1-java8-ibmsfj + springBoot2 + springBoot2-java8-ibm + springBoot2-java8-ibmsfj webProfile8 webProfile8-java8-ibm webProfile8-java8-ibmsfj @@ -94,6 +100,68 @@ The images are designed to support a number of different usage patterns. The fol --volumes-from app %%IMAGE%%:webProfile8 ``` +# Using `springBoot` images + +The `springBoot` images introduce capabilities specific to the support of Spring Boot applications, including the `springBootUtility` used to separate Spring Boot applications into thin applications and dependency library caches. To elaborate these capabilities this section assumes the standalone Spring Boot 2.0.x application `hellospringboot.jar` exists in the `/tmp` directory. + +1. A Spring Boot application JAR deploys to the `dropins/spring` directory within the default server configuration, not the `dropins` directory. Liberty allows one Spring Boot application per server configuration. The following example starts a container running a Spring Boot application. + + ```console + $ docker run -d -p 8080:9080 \ + -v /tmp/hellospringboot.jar:/config/dropins/spring/hellospringboot.jar \ + %%IMAGE%%:springBoot2 + ``` + + Similarly, you can create a Spring Boot application layer over this image by adding the application JAR to the `dropins/spring` directory. In this example we copied `hellospringboot.jar` from `/tmp` to the same directory containing the following Dockerfile. + + ```dockerfile + FROM %%IMAGE%%:springBoot2 + COPY hellospringboot.jar /config/dropins/spring/ + ``` + + The custom image can be built and run as follows. + + ```console + $ docker build -t app . + $ docker run -d -p 8080:9080 app + ``` + +2. The `springBoot` images provide the library cache directory, `lib.index.cache`, which contains an indexed library cache created by the `springBootUtility` command. Use `lib.index.cache` to provide the library cache for a thin application. + + For example, run the following command to thin the `hellospringboot.jar` application. + + ```console + $ /bin/springBootUtility thin \ + --sourceAppPath=/tmp/hellospringboot.jar \ + --targetLibCachePath=/tmp/lib.index.cache \ + --targetThinAppPath=/tmp/thinhellospringboot.jar + ``` + + You can run the thin application by mounting both the target application JAR and library cache when starting the container. + + ```console + $ docker run -d -p 8080:9080 \ + -v /tmp/thinhellospringboot.jar:/config/dropins/spring/thinhellospringboot.jar \ + -v /tmp/lib.index.cache:/lib.index.cache \ + %%IMAGE%%:springBoot2 + ``` + + Similarly, you can use the `springBootUtility` command to create thin application and library cache layers over a `springBoot` image. The following example uses docker staging to efficiently build an image that deploys a fat Spring Boot application as two layers containing a thin application and a library cache. + + ```dockerfile + FROM %%IMAGE%%:springBoot2 as staging + COPY hellospringboot.jar /staging/myFatApp.jar + RUN springBootUtility thin \ + --sourceAppPath=/staging/myFatApp.jar \ + --targetThinAppPath=/staging/myThinApp.jar \ + --targetLibCachePath=/staging/lib.index.cache + FROM %%IMAGE%%:springBoot2 + COPY --from=staging /staging/lib.index.cache /lib.index.cache + COPY --from=staging /staging/myThinApp.jar /config/dropins/spring/myThinApp.jar + ``` + + For Spring Boot applications packaged with library dependencies that rarely change across continuous application updates, you can use the capabilities mentioned above to to share library caches across containers and to create even more efficient docker layers that leverage the docker build cache. + # Providing your own keystore/truststore When an `open-liberty` image starts, it can generate a Liberty server XML snippet in `/config/configDropins/defaults/keystore.xml` that specifies a `keyStore` stanza with a generated password. This causes Open Liberty to generate a default keystore and truststore with a self-signed certificate when it starts. Images can request this by setting: diff --git a/websphere-liberty/content.md b/websphere-liberty/content.md index f06f2a9e4..6177c64bc 100644 --- a/websphere-liberty/content.md +++ b/websphere-liberty/content.md @@ -20,6 +20,8 @@ The `webProfile7` image contains the features required for Java EE7 Web Profile The `webProfile8`, `javaee8`, `webProfile7` and `javaee7` images also contain a common set of features that are expected to be of use for a typical production scenario. These features are: `appSecurity-2.0`, `collectiveMember-1.0`, `localConnector-1.0`, `ldapRegistry-3.0`, `monitor-1.0`, `requestTiming-1.0`, `restConnector-2.0`, `sessionDatabase-1.0`, `ssl-1.0`, `transportSecurity-1.0` and `webCache-1.0`. +The `springBoot1` and `springBoot2` images contain all features required for running Spring Boot 1.5 and 2.0 applications; including `springBoot-1.5` or `springBoot-2.0`, respectively, plus `servlet-4.0`, `jsp-2.3`, `webSocket-1.1`, and `transportSecurity-1.0`. + # Usage The images are designed to support a number of different usage patterns. The following examples are based on the Java EE8 Liberty [application deployment sample](https://developer.ibm.com/wasdev/docs/article_appdeployment/) and assume that [DefaultServletEngine.zip](https://github.com/WASdev/sample.servlet/releases/download/V1/DefaultServletEngine.zip) has been extracted to `/tmp` and the `server.xml` updated to accept HTTP connections from outside of the container by adding the following element inside the `server` stanza: @@ -84,6 +86,68 @@ The images are designed to support a number of different usage patterns. The fol --volumes-from app %%IMAGE%%:webProfile8 ``` +# Using `springBoot` images + +The `springBoot` images introduce capabilities specific to the support of Spring Boot applications, including the `springBootUtility` used to separate Spring Boot applications into thin applications and dependency library caches. To elaborate these capabilities this section assumes the standalone Spring Boot 2.0.x application `hellospringboot.jar` exists in the `/tmp` directory. + +1. A Spring Boot application JAR deploys to the `dropins/spring` directory within the default server configuration, not the `dropins` directory. Liberty allows one Spring Boot application per server configuration. The following example starts a container running a Spring Boot application. + + ```console + $ docker run -d -p 8080:9080 \ + -v /tmp/hellospringboot.jar:/config/dropins/spring/hellospringboot.jar \ + %%IMAGE%%:springBoot2 + ``` + + Similarly, you can create a Spring Boot application layer over this image by adding the application JAR to the `dropins/spring` directory. In this example we copied `hellospringboot.jar` from `/tmp` to the same directory containing the following Dockerfile. + + ```dockerfile + FROM %%IMAGE%%:springBoot2 + COPY hellospringboot.jar /config/dropins/spring/ + ``` + + The custom image can be built and run as follows. + + ```console + $ docker build -t app . + $ docker run -d -p 8080:9080 app + ``` + +2. The `springBoot` images provide the library cache directory, `lib.index.cache`, which contains an indexed library cache created by the `springBootUtility` command. Use `lib.index.cache` to provide the library cache for a thin application. + + For example, run the following command to thin the `hellospringboot.jar` application. + + ```console + $ /bin/springBootUtility thin \ + --sourceAppPath=/tmp/hellospringboot.jar \ + --targetLibCachePath=/tmp/lib.index.cache \ + --targetThinAppPath=/tmp/thinhellospringboot.jar + ``` + + You can run the thin application by mounting both the target application JAR and library cache when starting the container. + + ```console + $ docker run -d -p 8080:9080 \ + -v /tmp/thinhellospringboot.jar:/config/dropins/spring/thinhellospringboot.jar \ + -v /tmp/lib.index.cache:/lib.index.cache \ + %%IMAGE%%:springBoot2 + ``` + + Similarly, you can use the `springBootUtility` command to create thin application and library cache layers over a `springBoot` image. The following example uses docker staging to efficiently build an image that deploys a fat Spring Boot application as two layers containing a thin application and a library cache. + + ```dockerfile + FROM %%IMAGE%%:springBoot2 as staging + COPY hellospringboot.jar /staging/myFatApp.jar + RUN springBootUtility thin \ + --sourceAppPath=/staging/myFatApp.jar \ + --targetThinAppPath=/staging/myThinApp.jar \ + --targetLibCachePath=/staging/lib.index.cache + FROM %%IMAGE%%:springBoot2 + COPY --from=staging /staging/lib.index.cache /lib.index.cache + COPY --from=staging /staging/myThinApp.jar /config/dropins/spring/myThinApp.jar + ``` + + For Spring Boot applications packaged with library dependencies that rarely change across continuous application updates, you can use the capabilities mentioned above to to share library caches across containers and to create even more efficient docker layers that leverage the docker build cache. + # Providing your own keystore/truststore By default, when a `websphere-liberty` image starts, a Liberty server XML snippet is generated in `/config/configDropins/defaults/keystore.xml` that specifies a `keyStore` stanza with a generated password. This causes Liberty to generate a default keystore and truststore with a self-signed certificate when it starts (see the [Knowledge Center](https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/rwlp_liberty_ssl_defaults.html) for more information). When providing your own keystore/truststore, this default behavior can be disabled by ensuring that a file already exists at `/config/configDropins/defaults/keystore.xml` (for example, added as part of your Docker build). This file can contain your keystore configuration or could just contain an empty `` stanza.