OpenLiberty / ci.docker

Eclipse Public License 1.0
44 stars 59 forks source link

Docker OpenLiberty on Raspberry-Pi #192

Open Warkdev opened 4 years ago

Warkdev commented 4 years ago

Hello,

I've followed the following article but I couldn't make it work. At first, I got the error that yum package does not exist which is quite normal on Raspbian.

I've commented out yum lines as these packages are available by default on the system but I'm now having the following error:

image

It looks like the wget function didn't work properly, is that possible ?

Regards, Warkdev

Warkdev commented 4 years ago

Well well.. after digging into this, I came up with reworking few parts of the Dockerfile (I've used the file Dockerfile.ubi.adoptopenjdk14 as source) and here is my final version although I couldn't get it working with OPENJ9_SCC=true:

` FROM arm32v7/adoptopenjdk:14-jre-hotspot ARG LIBERTY_VERSION=20.0.0.6 ARG LIBERTY_SHA=083e89c2f96972df339a513582b338658e6562b3 ARG LIBERTY_BUILD_LABEL=cl200620200528-0414 ARG LIBERTY_DOWNLOAD_URL=https://repo1.maven.org/maven2/io/openliberty/openliberty-runtime/$LIBERTY_VERSION/openliberty-runtime-$LIBERTY_VERSION.zip ARG OPENJ9_SCC=false

LABEL org.opencontainers.image.authors="Arthur De Magalhaes, Chris Potter" \ org.opencontainers.image.vendor="Open Liberty" \ org.opencontainers.image.url="https://openliberty.io/" \ org.opencontainers.image.source="https://github.com/OpenLiberty/ci.docker" \ org.opencontainers.image.version="$LIBERTY_VERSION" \ org.opencontainers.image.revision="$LIBERTY_BUILD_LABEL" \ vendor="Open Liberty" \ name="Open Liberty" \ version="$LIBERTY_VERSION" \ summary="Image for Open Liberty with AdoptOpenJDK with OpenJ9 and UBI 8" \ description="This image contains the Open Liberty runtime with AdoptOpenJDK 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"

COPY helpers /opt/ol/helpers COPY fixes/ /opt/ol/fixes/ COPY licenses /licenses

--# Install Open Liberty RUN apt-get update \ && apt-get -y install wget unzip openssl \ && wget -q $LIBERTY_DOWNLOAD_URL -U UA-Open-Liberty-Docker -O /tmp/wlp.zip \ && echo "$LIBERTY_SHA /tmp/wlp.zip" > /tmp/wlp.zip.sha1 \ && sha1sum -c /tmp/wlp.zip.sha1 \ && chmod -R u+x /usr/bin \ && unzip -q /tmp/wlp.zip -d /opt/ol \ && rm /tmp/wlp.zip \ && rm /tmp/wlp.zip.sha1 \ && useradd -u 1001 -r -g root -s /usr/sbin/nologin default \ && apt-get -y remove wget unzip \ && apt-get clean all \ && chown -R 1001:0 /opt/ol/wlp \ && chmod -R g+rw /opt/ol/wlp

--# Set Path Shortcuts ENV PATH=/opt/ol/wlp/bin:/opt/ol/docker/:/opt/ol/helpers/build:$PATH \ LOG_DIR=/logs \ WLP_OUTPUT_DIR=/opt/ol/wlp/output \ WLP_SKIP_MAXPERMSIZE=true \ OPENJ9_SCC=$OPENJ9_SCC

--# Configure Open Liberty RUN /opt/ol/wlp/bin/server create \ && rm -rf $WLP_OUTPUT_DIR/.classCache /output/workarea

--# Create symlinks && set permissions for non-root user RUN mkdir /logs \ && mkdir -p /opt/ol/wlp/usr/shared/resources/lib.index.cache \ && ln -s /opt/ol/wlp/usr/shared/resources/lib.index.cache /lib.index.cache \ && mkdir -p $WLP_OUTPUT_DIR/defaultServer \ && ln -s $WLP_OUTPUT_DIR/defaultServer /output \ && ln -s /opt/ol/wlp/usr/servers/defaultServer /config \ && mkdir -p /config/configDropins/defaults \ && mkdir -p /config/configDropins/overrides \ && ln -s /opt/ol/wlp /liberty \ && chown -R 1001:0 /config \ && chmod -R g+rw /config \ && chown -R 1001:0 /logs \ && chmod -R g+rw /logs \ && chown -R 1001:0 /opt/ol/wlp/usr \ && chmod -R g+rw /opt/ol/wlp/usr \ && chown -R 1001:0 /opt/ol/wlp/output \ && chmod -R g+rw /opt/ol/wlp/output \ && chown -R 1001:0 /opt/ol/helpers \ && chmod -R g+rw /opt/ol/helpers \ && chown -R 1001:0 /opt/ol/fixes \ && chmod -R g+rwx /opt/ol/fixes \ && chown -R 1001:0 /opt/ol/helpers \ && chmod -R g+rwx /opt/ol/helpers \ && mkdir /etc/wlp \ && chown -R 1001:0 /etc/wlp \ && chmod -R g+rw /etc/wlp \ && echo "<server description=\"Default Server\"><httpEndpoint id=\"defaultHttpEndpoint\" host=\"*\" />" > /config/configDropins/defaults/open-default-port.xml

--# Create a new SCC layer RUN if [ "$OPENJ9_SCC" = "true" ]; then /opt/ol/helpers/build/populate_scc.sh; fi RUN rm -rf /output/messaging /output/resources/security /logs/* $WLP_OUTPUT_DIR/.classCache RUN chown -R 1001:0 /opt/ol/wlp/output RUN chmod -R g+rwx /opt/ol/wlp/output

--#These settings are needed so that we can run as a different user than 1001 after server warmup ENV RANDFILE=/tmp/.rnd \ IBM_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/ ${IBM_JAVA_OPTIONS}"

USER 1001

EXPOSE 9080 9443

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

arthurdm commented 4 years ago

thanks @Warkdev - were you able to pinpoint what was the key change you needed?

@ymanton - please note the comment about not getting this to work with SCC enabled. Any ideas here?

Warkdev commented 4 years ago

Hello,

Sure, first, set SCC to FALSE:

ARG OPENJ9_SCC=false

I couldn't get it working because the shell kept complaining about the if structure:

RUN if [ "$OPENJ9_SCC" = "true" ]; then /opt/ol/helpers/build/populate_scc.sh; fi

Then, I replace all yum byt apt-get and I removed shadow-utils dependency as it's already available.

Finally, I've replaced adduser by useradd command.

ymanton commented 4 years ago

FROM arm32v7/adoptopenjdk:14-jre-hotspot

You're using HotSpot, not OpenJ9, so the OpenJ9 SCC feature is not applicable. The code in the Dockerfile doesn't try to detect which JVM is being used, so disabling it manually is currently the only way to get around that.

Warkdev commented 4 years ago

Interesting, I must admit that I didn't look at this.

I could try using another openjdk version to see if that works then.

Thanks.

ymanton commented 4 years ago

OpenJ9 isn't available for 32-bit ARM so if you're primarily interested in the SCC you would have to move to a different architecture. OpenJ9 is recently available for aarch64 and is in active development, and also x86-64, s390x, and ppc64le.