Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaultServer name change feature #468

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
57242a8
Update helpers to use features.sh
kabicin Aug 22, 2022
e5de794
Add defaultServer name change feature
kabicin Aug 22, 2022
b8d9ad2
Update 22.0.0.8
kabicin Aug 22, 2022
9f8663d
Revert /opt/ibm/wlp/output chown
kabicin Aug 24, 2022
8eec931
Revert /opt/ibm/wlp/output chown for 22.0.0.8
kabicin Aug 24, 2022
308eeed
Update features install to use SERVER_NAME
kabicin Aug 25, 2022
5380a00
Update 22.0.0.8
kabicin Aug 25, 2022
6a3023e
Move defaultServer name change to new releases
kabicin May 30, 2023
63f73eb
Cleanup merge conflicting files
kabicin May 30, 2023
5ff1f77
Update copyright headers and support SERVER_NAME env
kabicin May 31, 2023
a25edb4
Initialize SERVER_NAME env with defaultServer
kabicin May 31, 2023
fca10e9
Update to always check for server name change
kabicin May 31, 2023
b93200d
Resolve changes from merge conflict
kabicin May 31, 2023
40f6027
Remove redundant variable in configure-liberty.sh
kabicin May 31, 2023
2f9704c
Update configure-liberty.sh and docs
kabicin Jun 13, 2023
24c4ea9
Re-add configuration_snippets
kabicin Jun 13, 2023
e57e517
Add defaultServer name change tests
kabicin Jun 14, 2023
113e80a
Delete configure-liberty.sh
kabicin Jul 10, 2023
eead2e2
Remove acl command in configure-liberty.sh
kabicin Jul 10, 2023
c3b903e
Add symlinks to 23.0.0.3 files
kabicin Jul 11, 2023
b42555e
Remove extra config folders
kabicin Jul 11, 2023
6e3bf84
Update USER command and re-add SERVER_NAME env
kabicin Jul 11, 2023
96caf19
Remove unneeded files from rebase
kabicin Jul 11, 2023
27363e3
Add SERVER_NAME env
kabicin Jul 11, 2023
e085570
Add SERVER_NAME usage into README
kabicin Jul 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi
# Default setting for the verbose option. Set it to true to debug the application container image build failures
ARG VERBOSE=false

# Modify the server name (optional)
ENV SERVER_NAME=liberty1

# Add Liberty server configuration including all necessary features
COPY --chown=1001:0 server.xml /config/

Expand Down Expand Up @@ -70,14 +73,20 @@ Refer to [Repository and proxy modifications](https://openliberty.io/docs/ref/co

## Optional Enterprise Functionality

This section describes the optional enterprise functionality that can be enabled via the Dockerfile during `build` time, by setting particular argument (`ARG`) or environment variable (`ENV`) and calling `RUN configure.sh`. Each of these options trigger the inclusion of specific configuration via XML snippets (except for `VERBOSE`), described below:
This section describes the optional enterprise functionality that can be enabled via the Dockerfile during `build` time, by setting particular argument (`ARG`) or environment variable (`ENV`) and calling `RUN configure.sh`. Each of these options trigger the inclusion of specific configuration via XML snippets (except for `SERVER_NAME` and `VERBOSE`), described below:

* `TLS` (`SSL` is deprecated)
* Description: Enable Transport Security in Liberty by adding the `transportSecurity-1.0` feature (includes support for SSL).
* XML Snippet Location: [keystore.xml](ga/latest/kernel/helpers/build/configuration_snippets/keystore.xml).
* `HZ_SESSION_CACHE`
* Description: Enable the persistence of HTTP sessions using JCache by adding the `sessionCache-1.0` feature.
* XML Snippet Location: [hazelcast-sessioncache.xml](ga/latest/kernel/helpers/build/configuration_snippets/hazelcast-sessioncache.xml)
* `SERVER_NAME`
* Description: A name for the server. If no server is specified, a server called `defaultServer` is automatically created.
* Naming constraints:
* Use only Unicode alphanumeric (e.g. 0-9, a-z, A-Z), underscore (_), dash (-), plus (+), and period (.) characters.
* Do not begin the name with a dash (-) or a period (.).
* Be aware that your file system, operating system, or compressed file directory might impose more restrictions.
* `VERBOSE`
* Description: When set to `true` it outputs the commands and results to stdout from `configure.sh`. Otherwise, default setting is `false` and `configure.sh` is silenced.

Expand Down
8 changes: 8 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Docs

This directory contains a number of useful guides.

## Table of Contents

* [Where to get Open Liberty container images](./icr-images.md)
* [How to customize your Liberty server](./liberty-server-customization.md)
66 changes: 66 additions & 0 deletions docs/liberty-server-customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

# How to customize your Liberty Server

## Provide a custom server name

You can provide a custom name for your Liberty server by specifying the `SERVER_NAME` environment variable at container image **build-time**.

### Building from a new image

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.
```Dockerfile
FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi

ENV SERVER_NAME=liberty1

RUN features.sh

RUN configure.sh
```
Running this container will produce output similar to:
```
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)
[AUDIT ] CWWKE0001I: The server liberty1 has been launched.
[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
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ibm/wlp/usr/servers/liberty1/configDropins/defaults/keystore.xml
[WARNING ] CWWKF0009W: The server has not been configured to install any features.
[AUDIT ] CWWKF0012I: The server installed the following features: [].
[AUDIT ] CWWKF0011I: The liberty1 server is ready to run a smarter planet. The liberty1 server started in 0.473 seconds.
```

### Renaming an existing Liberty server

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.

```Dockerfile
FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi as staging

ENV SERVER_NAME=liberty1

# Initialize server configuration
COPY --chown=1001:0 server.xml /config/

RUN features.sh

RUN configure.sh

# From an existing Liberty server
FROM staging

# Rename liberty1 to liberty2, retaining /config/server.xml from above
ENV SERVER_NAME=liberty2

RUN features.sh

RUN configure.sh
```

### Notes

The new server name changes the directory of stored configurations and server output. For example, for a custom server name `liberty1`.
- `/config -> /opt/ol/wlp/usr/servers/liberty1`
- `/output -> /opt/ol/wlp/output/liberty1`

By using the symbolic links `/config` and `/output`, you can always ensure a correct mapping to the Liberty server's directories.


46 changes: 34 additions & 12 deletions ga/23.0.0.3/kernel/Dockerfile.ubi.ibmjava8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) Copyright IBM Corporation 2019.
# (C) Copyright IBM Corporation 2019, 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ ARG EN_SHA=366618db4b733337adc71ec30b1f33d36cf78a81858636360061036a926f373f
ARG NON_IBM_SHA=d349f6ea3acd71910348904dd48f81940b86ca5f879737206ae37f858767ad0f
ARG NOTICES_SHA=e7031658e09e2442279db72eed9238fb30d98c06dabb112fb21b8618b7e810ee

ENV SERVER_NAME=defaultServer

LABEL org.opencontainers.image.authors="Leo Christy Jesuraj, Arthur De Magalhaes, Chris Potter" \
org.opencontainers.image.vendor="IBM" \
org.opencontainers.image.url="http://wasdev.net" \
Expand Down Expand Up @@ -85,18 +87,9 @@ RUN mkdir /logs \
&& mkdir /etc/wlp \
&& mkdir -p /opt/ibm/wlp/usr/shared/resources/lib.index.cache \
&& mkdir -p /home/default \
&& mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /config \
&& ln -s /opt/ibm /liberty \
&& ln -s /opt/ibm/fixes /fixes \
&& ln -s /opt/ibm/wlp/usr/shared/resources/lib.index.cache /lib.index.cache \
&& mkdir -p /config/configDropins/defaults \
&& mkdir -p /config/configDropins/overrides \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /opt/ibm/helpers \
&& chmod -R g+rwx /opt/ibm/helpers \
&& chown -R 1001:0 /opt/ibm/fixes \
Expand All @@ -110,7 +103,36 @@ RUN mkdir /logs \
&& chown -R 1001:0 /etc/wlp \
&& chmod -R g+rw /etc/wlp \
&& chown -R 1001:0 /home/default \
&& chmod -R g+rw /home/default
&& chmod -R g+rw /home/default \
&& mkdir -p /opt/ibm/links \
&& chown -R 1001:0 /opt/ibm/links \
&& chmod -R g+rw /opt/ibm/links

# Create second-level symlinks as non-root user
USER 1001

RUN mkdir -p $WLP_OUTPUT_DIR/defaultServer \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /opt/ibm/links/output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /opt/ibm/links/config \
&& mkdir -p /opt/ibm/links/config/configDropins/defaults \
&& mkdir -p /opt/ibm/links/config/configDropins/overrides

# Create first-level symlinks as root user
USER root

RUN mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s /opt/ibm/links/output /output \
&& ln -s /opt/ibm/links/config /config \
&& chown -R 1001:0 /opt/ibm/links/output \
&& chmod -R g+rw /opt/ibm/links/output \
&& chown -R 1001:0 /opt/ibm/links/config \
&& chmod -R g+rw /opt/ibm/links/config \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /output \
&& chmod -R g+rw /output

# Create a new SCC layer
RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
Expand All @@ -127,4 +149,4 @@ USER 1001
EXPOSE 9080 9443

ENTRYPOINT ["/opt/ibm/helpers/runtime/docker-server.sh"]
CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
CMD ["/opt/ibm/wlp/bin/server", "run"]
46 changes: 34 additions & 12 deletions ga/23.0.0.3/kernel/Dockerfile.ubi.openjdk11
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) Copyright IBM Corporation 2019.
# (C) Copyright IBM Corporation 2019, 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ ARG EN_SHA=366618db4b733337adc71ec30b1f33d36cf78a81858636360061036a926f373f
ARG NON_IBM_SHA=d349f6ea3acd71910348904dd48f81940b86ca5f879737206ae37f858767ad0f
ARG NOTICES_SHA=e7031658e09e2442279db72eed9238fb30d98c06dabb112fb21b8618b7e810ee

ENV SERVER_NAME=defaultServer

LABEL org.opencontainers.image.authors="Leo Christy Jesuraj, Arthur De Magalhaes, Chris Potter" \
org.opencontainers.image.vendor="IBM" \
org.opencontainers.image.url="http://wasdev.net" \
Expand Down Expand Up @@ -86,18 +88,9 @@ RUN mkdir /logs \
&& mkdir /etc/wlp \
&& mkdir -p /opt/ibm/wlp/usr/shared/resources/lib.index.cache \
&& mkdir -p /home/default \
&& mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /config \
&& ln -s /opt/ibm /liberty \
&& ln -s /opt/ibm/fixes /fixes \
&& ln -s /opt/ibm/wlp/usr/shared/resources/lib.index.cache /lib.index.cache \
&& mkdir -p /config/configDropins/defaults \
&& mkdir -p /config/configDropins/overrides \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /opt/ibm/helpers \
&& chmod -R g+rwx /opt/ibm/helpers \
&& chown -R 1001:0 /opt/ibm/fixes \
Expand All @@ -111,7 +104,36 @@ RUN mkdir /logs \
&& chown -R 1001:0 /etc/wlp \
&& chmod -R g+rw /etc/wlp \
&& chown -R 1001:0 /home/default \
&& chmod -R g+rw /home/default
&& chmod -R g+rw /home/default \
&& mkdir -p /opt/ibm/links \
&& chown -R 1001:0 /opt/ibm/links \
&& chmod -R g+rw /opt/ibm/links

# Create second-level symlinks as non-root user
USER 1001

RUN mkdir -p $WLP_OUTPUT_DIR/defaultServer \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /opt/ibm/links/output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /opt/ibm/links/config \
&& mkdir -p /opt/ibm/links/config/configDropins/defaults \
&& mkdir -p /opt/ibm/links/config/configDropins/overrides

# Create first-level symlinks as root user
USER root

RUN mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s /opt/ibm/links/output /output \
&& ln -s /opt/ibm/links/config /config \
&& chown -R 1001:0 /opt/ibm/links/output \
&& chmod -R g+rw /opt/ibm/links/output \
&& chown -R 1001:0 /opt/ibm/links/config \
&& chmod -R g+rw /opt/ibm/links/config \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /output \
&& chmod -R g+rw /output

# Create a new SCC layer
RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
Expand All @@ -128,4 +150,4 @@ USER 1001
EXPOSE 9080 9443

ENTRYPOINT ["/opt/ibm/helpers/runtime/docker-server.sh"]
CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
CMD ["/opt/ibm/wlp/bin/server", "run"]
46 changes: 34 additions & 12 deletions ga/23.0.0.3/kernel/Dockerfile.ubi.openjdk17
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) Copyright IBM Corporation 2019.
# (C) Copyright IBM Corporation 2019, 2023.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@ ARG EN_SHA=366618db4b733337adc71ec30b1f33d36cf78a81858636360061036a926f373f
ARG NON_IBM_SHA=d349f6ea3acd71910348904dd48f81940b86ca5f879737206ae37f858767ad0f
ARG NOTICES_SHA=e7031658e09e2442279db72eed9238fb30d98c06dabb112fb21b8618b7e810ee

ENV SERVER_NAME=defaultServer

LABEL org.opencontainers.image.authors="Leo Christy Jesuraj, Chris Potter, Melissa Lee" \
org.opencontainers.image.vendor="IBM" \
org.opencontainers.image.url="http://wasdev.net" \
Expand Down Expand Up @@ -86,18 +88,9 @@ RUN mkdir /logs \
&& mkdir /etc/wlp \
&& mkdir -p /opt/ibm/wlp/usr/shared/resources/lib.index.cache \
&& mkdir -p /home/default \
&& mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /config \
&& ln -s /opt/ibm /liberty \
&& ln -s /opt/ibm/fixes /fixes \
&& ln -s /opt/ibm/wlp/usr/shared/resources/lib.index.cache /lib.index.cache \
&& mkdir -p /config/configDropins/defaults \
&& mkdir -p /config/configDropins/overrides \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /opt/ibm/helpers \
&& chmod -R g+rwx /opt/ibm/helpers \
&& chown -R 1001:0 /opt/ibm/fixes \
Expand All @@ -111,7 +104,36 @@ RUN mkdir /logs \
&& chown -R 1001:0 /etc/wlp \
&& chmod -R g+rw /etc/wlp \
&& chown -R 1001:0 /home/default \
&& chmod -R g+rw /home/default
&& chmod -R g+rw /home/default \
&& mkdir -p /opt/ibm/links \
&& chown -R 1001:0 /opt/ibm/links \
&& chmod -R g+rw /opt/ibm/links

# Create second-level symlinks as non-root user
USER 1001

RUN mkdir -p $WLP_OUTPUT_DIR/defaultServer \
&& ln -s $WLP_OUTPUT_DIR/defaultServer /opt/ibm/links/output \
&& ln -s /opt/ibm/wlp/usr/servers/defaultServer /opt/ibm/links/config \
&& mkdir -p /opt/ibm/links/config/configDropins/defaults \
&& mkdir -p /opt/ibm/links/config/configDropins/overrides

# Create first-level symlinks as root user
USER root

RUN mkdir /output \
&& chmod -t /output \
&& rm -rf /output \
&& ln -s /opt/ibm/links/output /output \
&& ln -s /opt/ibm/links/config /config \
&& chown -R 1001:0 /opt/ibm/links/output \
&& chmod -R g+rw /opt/ibm/links/output \
&& chown -R 1001:0 /opt/ibm/links/config \
&& chmod -R g+rw /opt/ibm/links/config \
&& chown -R 1001:0 /config \
&& chmod -R g+rw /config \
&& chown -R 1001:0 /output \
&& chmod -R g+rw /output

# Create a new SCC layer
RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \
Expand All @@ -128,4 +150,4 @@ USER 1001
EXPOSE 9080 9443

ENTRYPOINT ["/opt/ibm/helpers/runtime/docker-server.sh"]
CMD ["/opt/ibm/wlp/bin/server", "run", "defaultServer"]
CMD ["/opt/ibm/wlp/bin/server", "run"]
Loading