From 471e034c347f642fbc058d86379ce86c89757f2d Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Fri, 4 Sep 2026 14:37:33 -0400 Subject: [PATCH 1/2] Add package installation helper script doc --- docs/package-helper.md | 96 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 docs/package-helper.md diff --git a/docs/package-helper.md b/docs/package-helper.md new file mode 100644 index 00000000..fe3aed3c --- /dev/null +++ b/docs/package-helper.md @@ -0,0 +1,96 @@ + +# package-helper.sh + +`package-helper.sh` is a build-time helper script used in multi-stage Dockerfiles to install RPM packages in a UBI Minimal builder image and selectively copy only the resulting binaries and shared libraries into a target WebSphere Liberty image on UBI Micro. + +It is located at `/liberty/helpers/build/package-helper.sh` inside the WebSphere Liberty image and is intended to be run at build time. + +## Usage + +``` +package-helper.sh --install [ ...] +package-helper.sh --copy [] +``` + +The two modes are designed to be run in sequence across two stages of a multi-stage Dockerfile: `--install` runs in the UBI Minimal builder stage and `--copy` runs in the Liberty UBI Micro application stage. + +## Environment variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `PKG_DIR` | `/tmp/pkg-files` | Staging directory used to pass collected files from the UBI Minimal builder to the Liberty UBI Micro application stage. | +| `VERBOSE` | _(unset)_ | Set to `true` to enable output. All output is suppressed by default. | + +## Modes + +### `--install [ ...]` + +Runs in the **UBI Minimal builder** stage. Installs the requested packages and automatically includes any packages pulled in as dependencies. It then collects the installed binaries and shared libraries, and stages them under `PKG_DIR` (defaults to `/tmp/pkg-files`) ready to be copied into the WebSphere Liberty application image on UBI Micro. The staging directory can be overridden by setting `PKG_DIR`, for example: + +``` +PKG_DIR=/tmp/my-pkg-files package-helper.sh --install procps-ng +``` + +### `--copy []` + +Runs in the **Liberty UBI Micro application** stage. Copies the staged files from `from-dir` (defaults to `/tmp/pkg-files`) into the root filesystem, skipping any file that already exists in the target image. After copying, it reports counts of copied and skipped files and removes the staging directory. The source directory can be overridden, for example: + +``` +package-helper.sh --copy /tmp/my-pkg-files +``` + +## Example Dockerfile (using `kernel-java25-openj9-ubi-micro`) + +```dockerfile +FROM icr.io/appcafe/websphere-liberty:kernel-java25-openj9-ubi-micro AS helper + +FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS builder + +# Set to `true` to enable output +# ARG VERBOSE=true + +# Copy helper script to minimal builder +# And install requested packages +COPY --from=helper /liberty/helpers/build/package-helper.sh /tmp/package-helper.sh +RUN /tmp/package-helper.sh --install procps-ng net-tools ncurses hostname + +FROM icr.io/appcafe/websphere-liberty:kernel-java25-openj9-ubi-micro + +# Set to `true` to enable output +# ARG VERBOSE=true +... + +# Copy packages from UBI Minimal builder +COPY --from=builder /tmp/pkg-files /tmp/pkg-files +USER 0 +RUN /liberty/helpers/build/package-helper.sh --copy +USER 1001 +``` + +## Example Dockerfile with custom staging directory and VERBOSE enabled (using `kernel-java17-openj9-ubi-micro`) + +```dockerfile +FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi-micro AS helper + +FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS builder + +# Enabled output +ARG VERBOSE=true + +# Copy helper script to minimal builder +# And install requested packages into a custom staging directory +COPY --from=helper /liberty/helpers/build/package-helper.sh /tmp/package-helper.sh +RUN PKG_DIR=/tmp/my-pkg-files /tmp/package-helper.sh --install procps-ng net-tools ncurses hostname + +FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi-micro + +# Enabled output +ARG VERBOSE=true +... + +# Copy packages from UBI Minimal builder using custom staging directory +COPY --from=builder /tmp/my-pkg-files /tmp/my-pkg-files +USER 0 +RUN /liberty/helpers/build/package-helper.sh --copy /tmp/my-pkg-files +USER 1001 +``` \ No newline at end of file From c274e8c2616cccdc9c01f57ee317eb9e91bab434 Mon Sep 17 00:00:00 2001 From: Melissa Lee Date: Fri, 4 Sep 2026 14:39:29 -0400 Subject: [PATCH 2/2] Comment edits --- docs/package-helper.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/package-helper.md b/docs/package-helper.md index fe3aed3c..cebdbd80 100644 --- a/docs/package-helper.md +++ b/docs/package-helper.md @@ -46,7 +46,7 @@ FROM icr.io/appcafe/websphere-liberty:kernel-java25-openj9-ubi-micro AS helper FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS builder -# Set to `true` to enable output +# Set to true to enable output # ARG VERBOSE=true # Copy helper script to minimal builder @@ -56,8 +56,9 @@ RUN /tmp/package-helper.sh --install procps-ng net-tools ncurses hostname FROM icr.io/appcafe/websphere-liberty:kernel-java25-openj9-ubi-micro -# Set to `true` to enable output +# Set to true to enable output # ARG VERBOSE=true + ... # Copy packages from UBI Minimal builder @@ -65,6 +66,8 @@ COPY --from=builder /tmp/pkg-files /tmp/pkg-files USER 0 RUN /liberty/helpers/build/package-helper.sh --copy USER 1001 + +... ``` ## Example Dockerfile with custom staging directory and VERBOSE enabled (using `kernel-java17-openj9-ubi-micro`) @@ -86,6 +89,7 @@ FROM icr.io/appcafe/websphere-liberty:kernel-java17-openj9-ubi-micro # Enabled output ARG VERBOSE=true + ... # Copy packages from UBI Minimal builder using custom staging directory @@ -93,4 +97,6 @@ COPY --from=builder /tmp/my-pkg-files /tmp/my-pkg-files USER 0 RUN /liberty/helpers/build/package-helper.sh --copy /tmp/my-pkg-files USER 1001 + +... ``` \ No newline at end of file