|
| 1 | +FROM icr.io/appcafe/ibm-semeru-runtimes:open-11-jdk-ubi AS getRuntime |
| 2 | + |
| 3 | +USER root |
| 4 | + |
| 5 | +ARG LIBERTY_VERSION=25.0.0.4 |
| 6 | +ARG LIBERTY_SHA=719ffc20a113a68f88dea0295fc366606a4c6028 |
| 7 | +ARG LIBERTY_DOWNLOAD_URL=https://repo1.maven.org/maven2/io/openliberty/openliberty-runtime/$LIBERTY_VERSION/openliberty-runtime-$LIBERTY_VERSION.zip |
| 8 | + |
| 9 | +ARG VERBOSE=false |
| 10 | + |
| 11 | +# If there is a local copy of the image use that instead |
| 12 | +COPY resources/ /tmp/ |
| 13 | + |
| 14 | +# Install Open Liberty |
| 15 | +RUN yum -y install shadow-utils wget unzip openssl \ |
| 16 | + && if [ ! -f /tmp/wlp.zip ]; then wget -q $LIBERTY_DOWNLOAD_URL -U UA-Open-Liberty-Docker -O /tmp/wlp.zip; fi \ |
| 17 | + && echo "$LIBERTY_SHA /tmp/wlp.zip" > /tmp/wlp.zip.sha1 \ |
| 18 | + && sha1sum -c /tmp/wlp.zip.sha1 \ |
| 19 | + && chmod -R u+x /usr/bin \ |
| 20 | + && unzip -q /tmp/wlp.zip -d /opt/ol \ |
| 21 | + && mkdir -p /licenses \ |
| 22 | + && cp /opt/ol/wlp/LICENSE /licenses/ \ |
| 23 | + && adduser -u 1001 -r -g root -s /usr/sbin/nologin default \ |
| 24 | + && chown -R 1001:0 /opt/ol/wlp \ |
| 25 | + && chmod -R g+rw /opt/ol/wlp |
| 26 | + |
| 27 | +FROM icr.io/appcafe/ibm-semeru-runtimes:open-11-jdk-ubi |
| 28 | + |
| 29 | +USER root |
| 30 | + |
| 31 | +ARG LIBERTY_VERSION=25.0.0.4 |
| 32 | +ARG LIBERTY_BUILD_LABEL=cl250420250407-1902 |
| 33 | + |
| 34 | +ARG OPENJ9_SCC=true |
| 35 | +ARG VERBOSE=false |
| 36 | + |
| 37 | +LABEL org.opencontainers.image.authors="Leo Christy Jesuraj, Melissa Lee, Thomas Watson, Michal Broz, Wendy Raschke" \ |
| 38 | + org.opencontainers.image.vendor="Open Liberty" \ |
| 39 | + org.opencontainers.image.url="https://openliberty.io/" \ |
| 40 | + org.opencontainers.image.source="https://github.com/OpenLiberty/ci.docker" \ |
| 41 | + org.opencontainers.image.version="$LIBERTY_VERSION" \ |
| 42 | + org.opencontainers.image.revision="$LIBERTY_BUILD_LABEL" \ |
| 43 | + liberty.version="$LIBERTY_VERSION" \ |
| 44 | + io.openliberty.version="$LIBERTY_VERSION" \ |
| 45 | + vendor="Open Liberty" \ |
| 46 | + name="Open Liberty" \ |
| 47 | + version="$LIBERTY_VERSION" \ |
| 48 | + summary="Image for Open Liberty with IBM Semeru Runtime Open Edition OpenJDK with OpenJ9 and UBI 8" \ |
| 49 | + description="This image contains the Open Liberty runtime with IBM Semeru Runtime Open Edition OpenJDK with OpenJ9 and Red Hat UBI 8 as the base OS. For more information on this image please see https://github.com/OpenLiberty/ci.docker#building-an-application-image" |
| 50 | + |
| 51 | +COPY NOTICES /opt/ol/NOTICES |
| 52 | +COPY helpers /opt/ol/helpers |
| 53 | +COPY fixes/ /opt/ol/fixes/ |
| 54 | + |
| 55 | +# Install dumb-init |
| 56 | +RUN set -eux; \ |
| 57 | + ARCH="$(uname -m)"; \ |
| 58 | + case "${ARCH}" in \ |
| 59 | + aarch64|arm64) \ |
| 60 | + DUMB_INIT_URL='https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_aarch64'; \ |
| 61 | + DUMB_INIT_SHA256=b7d648f97154a99c539b63c55979cd29f005f88430fb383007fe3458340b795e; \ |
| 62 | + ;; \ |
| 63 | + amd64|x86_64) \ |
| 64 | + DUMB_INIT_URL='https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64'; \ |
| 65 | + DUMB_INIT_SHA256=e874b55f3279ca41415d290c512a7ba9d08f98041b28ae7c2acb19a545f1c4df; \ |
| 66 | + ;; \ |
| 67 | + ppc64el|ppc64le) \ |
| 68 | + DUMB_INIT_URL='https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_ppc64le'; \ |
| 69 | + DUMB_INIT_SHA256=3d15e80e29f0f4fa1fc686b00613a2220bc37e83a35283d4b4cca1fbd0a5609f; \ |
| 70 | + ;; \ |
| 71 | + s390x) \ |
| 72 | + DUMB_INIT_URL='https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_s390x'; \ |
| 73 | + DUMB_INIT_SHA256=47e4601b152fc6dcb1891e66c30ecc62a2939fd7ffd1515a7c30f281cfec53b7; \ |
| 74 | + ;;\ |
| 75 | + *) \ |
| 76 | + echo "Unsupported arch: ${ARCH}"; \ |
| 77 | + exit 1; \ |
| 78 | + ;; \ |
| 79 | + esac; \ |
| 80 | + curl -LfsSo /usr/bin/dumb-init ${DUMB_INIT_URL}; \ |
| 81 | + echo "${DUMB_INIT_SHA256} */usr/bin/dumb-init" | sha256sum -c -; \ |
| 82 | + chmod +x /usr/bin/dumb-init; |
| 83 | + |
| 84 | +# Add default user 1001 and create wlp with right user/permissions before copying |
| 85 | +RUN adduser -u 1001 -r -g root -s /usr/sbin/nologin default \ |
| 86 | + && mkdir -p /opt/ol/wlp \ |
| 87 | + && chown -R 1001:0 /opt/ol/wlp \ |
| 88 | + && chmod -R g+rw /opt/ol/wlp |
| 89 | + |
| 90 | +# Copy the runtime and licenses |
| 91 | +COPY --from=getRuntime --chown=1001:0 /opt/ol/wlp /opt/ol/wlp |
| 92 | +COPY --from=getRuntime /licenses /licenses |
| 93 | + |
| 94 | +RUN yum -y install openssl \ |
| 95 | + && yum clean all |
| 96 | + |
| 97 | +# Set Path Shortcuts |
| 98 | +ENV PATH=$PATH:/opt/ol/wlp/bin:/opt/ol/helpers/build \ |
| 99 | + LOG_DIR=/logs \ |
| 100 | + WLP_OUTPUT_DIR=/opt/ol/wlp/output \ |
| 101 | + WLP_SKIP_MAXPERMSIZE=true \ |
| 102 | + OPENJ9_SCC=$OPENJ9_SCC |
| 103 | + |
| 104 | +# Configure Open Liberty |
| 105 | +RUN /opt/ol/wlp/bin/server create --template=javaee8 \ |
| 106 | + && rm -rf $WLP_OUTPUT_DIR/.classCache /output/workarea \ |
| 107 | + && rm -rf /opt/ol/wlp/usr/servers/defaultServer/server.env |
| 108 | + |
| 109 | +# Create symlinks && set permissions for non-root user |
| 110 | +RUN mkdir /logs \ |
| 111 | + && mkdir -p /opt/ol/wlp/usr/shared/resources/lib.index.cache \ |
| 112 | + && ln -s /opt/ol/wlp/usr/shared/resources/lib.index.cache /lib.index.cache \ |
| 113 | + && mkdir -p $WLP_OUTPUT_DIR/defaultServer \ |
| 114 | + && ln -s $WLP_OUTPUT_DIR/defaultServer /output \ |
| 115 | + && ln -s /opt/ol/wlp/usr/servers/defaultServer /config \ |
| 116 | + && mkdir -p /config/configDropins/defaults \ |
| 117 | + && mkdir -p /config/configDropins/overrides \ |
| 118 | + && mkdir -p /config/dropins \ |
| 119 | + && mkdir -p /config/apps \ |
| 120 | + && ln -s /opt/ol/wlp /liberty \ |
| 121 | + && ln -s /opt/ol/fixes /fixes \ |
| 122 | + && chown -R 1001:0 /config \ |
| 123 | + && chmod -R g+rw /config \ |
| 124 | + && chown -R 1001:0 /logs \ |
| 125 | + && chmod -R g+rw /logs \ |
| 126 | + && chown -R 1001:0 /opt/ol/wlp/usr \ |
| 127 | + && chmod -R g+rw /opt/ol/wlp/usr \ |
| 128 | + && chown -R 1001:0 /opt/ol/wlp/output \ |
| 129 | + && chmod -R g+rw /opt/ol/wlp/output \ |
| 130 | + && chown -R 1001:0 /opt/ol/helpers \ |
| 131 | + && chmod -R ug+rwx /opt/ol/helpers \ |
| 132 | + && chown -R 1001:0 /opt/ol/fixes \ |
| 133 | + && chmod -R g+rwx /opt/ol/fixes \ |
| 134 | + && mkdir /etc/wlp \ |
| 135 | + && chown -R 1001:0 /etc/wlp \ |
| 136 | + && chmod -R g+rw /etc/wlp \ |
| 137 | + && if [ -e /etc/instanton.ld.so.cache ]; then chmod g+w /etc/ld.so.cache; fi \ |
| 138 | + && echo "<server description=\"Default Server\"><httpEndpoint id=\"defaultHttpEndpoint\" host=\"*\" /></server>" > /config/configDropins/defaults/open-default-port.xml |
| 139 | + |
| 140 | +# Create a new SCC layer |
| 141 | +RUN if [ "$OPENJ9_SCC" = "true" ]; then populate_scc.sh; fi \ |
| 142 | + && rm -rf /output/messaging /output/resources/security /logs/* $WLP_OUTPUT_DIR/.classCache \ |
| 143 | + && chown -R 1001:0 /opt/ol/wlp/output \ |
| 144 | + && chmod -R g+rwx /opt/ol/wlp/output |
| 145 | + |
| 146 | +#These settings are needed so that we can run as a different user than 1001 after server warmup |
| 147 | +ENV RANDFILE=/tmp/.rnd \ |
| 148 | + OPENJ9_JAVA_OPTIONS="-XX:+IgnoreUnrecognizedVMOptions -XX:+IdleTuningGcOnIdle -Xshareclasses:name=openj9_system_scc,cacheDir=/opt/java/.scc,readonly,nonFatal -Dosgi.checkConfiguration=false" |
| 149 | + |
| 150 | +USER 1001 |
| 151 | + |
| 152 | +EXPOSE 9080 9443 |
| 153 | + |
| 154 | +ENTRYPOINT ["/opt/ol/helpers/runtime/docker-server.sh"] |
| 155 | +CMD ["/opt/ol/wlp/bin/server", "run", "defaultServer"] |
0 commit comments