Skip to content

Commit 0186a6c

Browse files
committed
Update configure-liberty.sh and docs
1 parent 2b42ed7 commit 0186a6c

File tree

6 files changed

+106
-8
lines changed

6 files changed

+106
-8
lines changed

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Docs
2+
3+
This directory contains a number of useful guides.
4+
5+
## Table of Contents
6+
7+
* [Where to get Open Liberty container images](./icr-images.md)
8+
* [How to customize your Liberty server](./liberty-server-customization.md)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
# How to customize your Liberty Server
3+
4+
## Provide a custom server name
5+
6+
You can provide a custom name for your Liberty server by specifying the `SERVER_NAME` environment variable at container image **build-time**.
7+
8+
### Building from a new image
9+
10+
Specifying the `ENV SERVER_NAME=<your-server-name>` variable allows you to run a Liberty server with a custom name, as in the Dockerfile below.
11+
```Dockerfile
12+
FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi
13+
14+
ENV SERVER_NAME=liberty1
15+
16+
RUN features.sh
17+
18+
RUN configure.sh
19+
```
20+
Running this container will produce output similar to:
21+
```
22+
Launching liberty1 (WebSphere Application Server 23.0.0.5/wlp-1.0.77.cl230520230514-1901) on Eclipse OpenJ9 VM, version 17.0.7+7 (en_US)
23+
[AUDIT ] CWWKE0001I: The server liberty1 has been launched.
24+
[AUDIT ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/23.0.0.5/lafiles/en.html
25+
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ibm/wlp/usr/servers/liberty1/configDropins/defaults/keystore.xml
26+
[WARNING ] CWWKF0009W: The server has not been configured to install any features.
27+
[AUDIT ] CWWKF0012I: The server installed the following features: [].
28+
[AUDIT ] CWWKF0011I: The liberty1 server is ready to run a smarter planet. The liberty1 server started in 0.473 seconds.
29+
```
30+
31+
### Renaming an existing Liberty server
32+
33+
Liberty server configurations and existing output data under `/config` and `/output`, respectively, will be relocated to the server with new name, allowing you to **rename** servers `FROM` any Liberty image.
34+
35+
```Dockerfile
36+
FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi as staging
37+
38+
ENV SERVER_NAME=liberty1
39+
40+
# Initialize server configuration
41+
COPY --chown=1001:0 server.xml /config/
42+
43+
RUN features.sh
44+
45+
RUN configure.sh
46+
47+
# From an existing Liberty server
48+
FROM staging
49+
50+
# Rename liberty1 to liberty2, retaining /config/server.xml from above
51+
ENV SERVER_NAME=liberty2
52+
53+
RUN features.sh
54+
55+
RUN configure.sh
56+
```
57+
58+
### Notes
59+
60+
The new server name changes the directory of stored configurations and server output. For example, for a custom server name `liberty1`.
61+
- `/config -> /opt/ol/wlp/usr/servers/liberty1`
62+
- `/output -> /opt/ol/wlp/output/liberty1`
63+
64+
By using the symbolic links `/config` and `/output`, you can always ensure a correct mapping to the Liberty server's directories.
65+
66+

ga/22.0.0.12/kernel/helpers/build/configure-liberty.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

33
OPT_PREFIX="/opt/ibm"
4-
ORIGINAL_SERVER_NAME="defaultServer"
54
IS_KERNEL=false
65

7-
# If the Liberty server name is not defaultServer and defaultServer still exists migrate the contents
6+
# Get the original server name
7+
NUM_SERVERS=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | wc -l)
8+
if [ $NUM_SERVERS -gt 0 ]; then
9+
ORIGINAL_SERVER_NAME=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | head -1)
10+
fi
11+
ORIGINAL_SERVER_NAME=${ORIGINAL_SERVER_NAME:-defaultServer}
12+
13+
# If the Liberty server name does not match the original server name then migrate the contents
814
if [ "$SERVER_NAME" != "$ORIGINAL_SERVER_NAME" ] && [ -d "$OPT_PREFIX/wlp/usr/servers/$ORIGINAL_SERVER_NAME" ]; then
915
# Create new Liberty server
1016
if $IS_KERNEL; then

ga/23.0.0.3/kernel/helpers/build/configure-liberty.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

33
OPT_PREFIX="/opt/ibm"
4-
ORIGINAL_SERVER_NAME="defaultServer"
54
IS_KERNEL=false
65

7-
# If the Liberty server name is not defaultServer and defaultServer still exists migrate the contents
6+
# Get the original server name
7+
NUM_SERVERS=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | wc -l)
8+
if [ $NUM_SERVERS -gt 0 ]; then
9+
ORIGINAL_SERVER_NAME=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | head -1)
10+
fi
11+
ORIGINAL_SERVER_NAME=${ORIGINAL_SERVER_NAME:-defaultServer}
12+
13+
# If the Liberty server name does not match the original server name then migrate the contents
814
if [ "$SERVER_NAME" != "$ORIGINAL_SERVER_NAME" ] && [ -d "$OPT_PREFIX/wlp/usr/servers/$ORIGINAL_SERVER_NAME" ]; then
915
# Create new Liberty server
1016
if $IS_KERNEL; then

ga/23.0.0.5/kernel/helpers/build/configure-liberty.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

33
OPT_PREFIX="/opt/ibm"
4-
ORIGINAL_SERVER_NAME="defaultServer"
54
IS_KERNEL=false
65

7-
# If the Liberty server name is not defaultServer and defaultServer still exists migrate the contents
6+
# Get the original server name
7+
NUM_SERVERS=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | wc -l)
8+
if [ $NUM_SERVERS -gt 0 ]; then
9+
ORIGINAL_SERVER_NAME=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | head -1)
10+
fi
11+
ORIGINAL_SERVER_NAME=${ORIGINAL_SERVER_NAME:-defaultServer}
12+
13+
# If the Liberty server name does not match the original server name then migrate the contents
814
if [ "$SERVER_NAME" != "$ORIGINAL_SERVER_NAME" ] && [ -d "$OPT_PREFIX/wlp/usr/servers/$ORIGINAL_SERVER_NAME" ]; then
915
# Create new Liberty server
1016
if $IS_KERNEL; then

ga/latest/kernel/helpers/build/configure-liberty.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

33
OPT_PREFIX="/opt/ibm"
4-
ORIGINAL_SERVER_NAME="defaultServer"
54
IS_KERNEL=false
65

7-
# If the Liberty server name is not defaultServer and defaultServer still exists migrate the contents
6+
# Get the original server name
7+
NUM_SERVERS=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | wc -l)
8+
if [ $NUM_SERVERS -gt 0 ]; then
9+
ORIGINAL_SERVER_NAME=$(ls -t $OPT_PREFIX/wlp/usr/servers/ | head -1)
10+
fi
11+
ORIGINAL_SERVER_NAME=${ORIGINAL_SERVER_NAME:-defaultServer}
12+
13+
# If the Liberty server name does not match the original server name then migrate the contents
814
if [ "$SERVER_NAME" != "$ORIGINAL_SERVER_NAME" ] && [ -d "$OPT_PREFIX/wlp/usr/servers/$ORIGINAL_SERVER_NAME" ]; then
915
# Create new Liberty server
1016
if $IS_KERNEL; then

0 commit comments

Comments
 (0)