From 86a6c9486ac781d662b8e3837651a948aa8843f1 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 8 Mar 2019 20:34:34 +0100 Subject: [PATCH 01/18] add Native S2I Builder image v0.1 (#304) --- docker/centos-graal-maven-s2i/Dockerfile | 55 ++++++++++++++++++++++ docker/centos-graal-maven-s2i/README.md | 30 ++++++++++++ docker/centos-graal-maven-s2i/s2i/assemble | 12 +++++ docker/centos-graal-maven-s2i/s2i/run | 7 +++ 4 files changed, 104 insertions(+) create mode 100644 docker/centos-graal-maven-s2i/Dockerfile create mode 100644 docker/centos-graal-maven-s2i/README.md create mode 100644 docker/centos-graal-maven-s2i/s2i/assemble create mode 100644 docker/centos-graal-maven-s2i/s2i/run diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile new file mode 100644 index 0000000000000..90fdff1a580be --- /dev/null +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -0,0 +1,55 @@ +# [Quarkus.io](http://quarkus.io) *native* S2I builder +# Original Author: Michael Vorburger.ch + +# This part is heavily inspired by ../centos-graal/Dockerfile +FROM centos:latest + +ARG GRAAL_VERSION +ENV GRAAL_VERSION=${GRAAL_VERSION:-1.0.0-rc12} +ARG MAVEN_VERSION=3.6.0 + +ENV GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz +ENV MAVEN_URL=http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz + +ENV JAVA_HOME=/opt/graalvm +ENV PATH=$PATH:$JAVA_HOME/bin +ENV GRAALVM_HOME=/opt/graalvm + +RUN yum update -y && \ + yum install -y --setopt=skip_missing_names_on_install=False \ + tar gzip gcc glibc-devel zlib-devel curl && \ + mkdir -p /opt/graalvm && \ + cd /opt/graalvm && \ + curl -fsSL $GRAAL_CE_URL | tar -xzC /opt/graalvm --strip-components=1 && \ + +# This part is inspired by ../centos-graal-maven/Dockerfile and fabric8io-images/s2i + + mkdir -p /usr/share/maven && \ + curl -fsSL ${MAVEN_URL} | tar -xzC /usr/share/maven --strip-components=1 && \ + ln -s /usr/share/maven/bin/mvn /usr/bin/mvn + +ENV MAVEN_HOME /usr/share/maven +ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" +ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1" + +# This part is firmly inspired by fabric8io-images/s2i + +LABEL io.openshift.s2i.scripts-url="image:///usr/local/s2i" \ + io.openshift.s2i.destination="/tmp" \ + + io.k8s.description="Platform for building and running Quarkus.io NATIVE Java applications" \ + io.k8s.display-name="Quarkus.io NATIVE Java Applications" \ + io.openshift.tags="builder,java,quarkus,native" + +# S2I scripts + README +COPY s2i /usr/local/s2i +RUN chmod 755 /usr/local/s2i/* +ADD README.md /usr/local/s2i/usage.txt + +ENV PATH=$PATH:"/usr/local/s2i" + +RUN mkdir /quarkus.io/ + +# Use the run script as default since we are working as an hybrid image which can be +# used directly to. (If we were a plain s2i image we would print the usage info here.) +CMD [ "/usr/local/s2i/run" ] diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md new file mode 100644 index 0000000000000..a9dc39a551db6 --- /dev/null +++ b/docker/centos-graal-maven-s2i/README.md @@ -0,0 +1,30 @@ +# [Quarkus.io](http://quarkus.io) native S2I + +## How to build this S2I builder image + +### OpenShift + + oc new-build https://github.com/quarkusio/quarkus.git --context-dir=docker/centos-graal-maven-s2i --name quarkus-native-s2i + +### Locally + + docker build . -t quarkus-native-s2i + +## How to use this + +### OpenShift + + oc new-app quarkus-native-s2i~https://github.com/quarkusio/quarkus-quickstarts --context-dir=getting-started-native --name=getting-started-native + +Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds, +and you therefore may need to increase the quota for OpenShift's S2I builder containers. + +### Locally + + sudo dnf install source-to-image + + s2i build --copy ../../../quarkus-quickstarts/getting-started-native quarkus-native-s2i getting-started-native + + docker run --rm -it -p 8080:8080 getting-started-native + + curl http://localhost:8080/hello/greeting/quarkus diff --git a/docker/centos-graal-maven-s2i/s2i/assemble b/docker/centos-graal-maven-s2i/s2i/assemble new file mode 100644 index 0000000000000..ebfe3848e4517 --- /dev/null +++ b/docker/centos-graal-maven-s2i/s2i/assemble @@ -0,0 +1,12 @@ +#!/bin/sh + +# This POC script is based on the openshift/source-to-image project documentation, +# and loosely inspired by fabric8io-images/s2i's assemble script, but **MUCH** simplified; +# a TODO future PRODUCTION version of this would probably want to re-use that script... + +set -ex + +cd /tmp/src/ +mvn package -Pnative -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true -e -B +cp target/*-runner /quarkus.io/ + diff --git a/docker/centos-graal-maven-s2i/s2i/run b/docker/centos-graal-maven-s2i/s2i/run new file mode 100644 index 0000000000000..790d0cbd7dd84 --- /dev/null +++ b/docker/centos-graal-maven-s2i/s2i/run @@ -0,0 +1,7 @@ +#!/bin/sh + +# This POC script is (intentionally) overly trivial. +# a TODO future PRODUCTION version of this would probably want tomake it possible to +# e.g. pass additional parameters to the executable, as does fabric8io-images/s2i's run script. + +/quarkus.io/*-runner -Dquarkus.http.host=0.0.0.0 From d9719894fff1ea1e9959ac807c256efde8f111e5 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Fri, 8 Mar 2019 20:35:12 +0100 Subject: [PATCH 02/18] add 'EXPOSE 8080' to native S2I builder Dockerfile --- docker/centos-graal-maven-s2i/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index 90fdff1a580be..7b2a687be5a1c 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -50,6 +50,8 @@ ENV PATH=$PATH:"/usr/local/s2i" RUN mkdir /quarkus.io/ +EXPOSE 8080 + # Use the run script as default since we are working as an hybrid image which can be # used directly to. (If we were a plain s2i image we would print the usage info here.) CMD [ "/usr/local/s2i/run" ] From 0f677d685294e49daf390a3252ad217b0eb068b8 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Fri, 8 Mar 2019 22:36:55 +0100 Subject: [PATCH 03/18] Minor label spelling update docker/centos-graal-maven-s2i/Dockerfile Co-Authored-By: vorburger --- docker/centos-graal-maven-s2i/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index 7b2a687be5a1c..d018943eb6244 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -37,7 +37,7 @@ ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1" LABEL io.openshift.s2i.scripts-url="image:///usr/local/s2i" \ io.openshift.s2i.destination="/tmp" \ - io.k8s.description="Platform for building and running Quarkus.io NATIVE Java applications" \ + io.k8s.description="Platform for building and running Quarkus.io Native Java applications" \ io.k8s.display-name="Quarkus.io NATIVE Java Applications" \ io.openshift.tags="builder,java,quarkus,native" From 43cd78b8b971483b1c56ea67b1a96aa63af40010 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Fri, 8 Mar 2019 22:39:11 +0100 Subject: [PATCH 04/18] use better Maven DL URL in Native S2I Dockerfile Co-Authored-By: vorburger --- docker/centos-graal-maven-s2i/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index d018943eb6244..cf51222c1e26b 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -9,7 +9,7 @@ ENV GRAAL_VERSION=${GRAAL_VERSION:-1.0.0-rc12} ARG MAVEN_VERSION=3.6.0 ENV GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz -ENV MAVEN_URL=http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz +ENV MAVEN_URL=https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz ENV JAVA_HOME=/opt/graalvm ENV PATH=$PATH:$JAVA_HOME/bin @@ -38,7 +38,7 @@ LABEL io.openshift.s2i.scripts-url="image:///usr/local/s2i" \ io.openshift.s2i.destination="/tmp" \ io.k8s.description="Platform for building and running Quarkus.io Native Java applications" \ - io.k8s.display-name="Quarkus.io NATIVE Java Applications" \ + io.k8s.display-name="Quarkus.io Native Java Applications" \ io.openshift.tags="builder,java,quarkus,native" # S2I scripts + README From 335cdfbd03e08a1305725862300fb9955149ebf1 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 10 Mar 2019 13:27:40 +0100 Subject: [PATCH 05/18] improve graal-maven-s2i Dockerfile io.k8s.* LABELs as suggested by @cescoffier during code review --- docker/centos-graal-maven-s2i/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index cf51222c1e26b..7da5f1987c6c3 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -37,8 +37,8 @@ ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1" LABEL io.openshift.s2i.scripts-url="image:///usr/local/s2i" \ io.openshift.s2i.destination="/tmp" \ - io.k8s.description="Platform for building and running Quarkus.io Native Java applications" \ - io.k8s.display-name="Quarkus.io Native Java Applications" \ + io.k8s.description="Quarkus.io S2I image for building Kubernetes Native Java GraalVM applications and running its Native Executables" \ + io.k8s.display-name="Quarkus.io S2I (GraalVM Native)" \ io.openshift.tags="builder,java,quarkus,native" # S2I scripts + README From 9fb4604421106cdc5c724bd7082422cc8770b726 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 10 Mar 2019 13:28:20 +0100 Subject: [PATCH 06/18] move -e -B in GraalVM S2I assemble script (and multiline) --- docker/centos-graal-maven-s2i/s2i/assemble | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/s2i/assemble b/docker/centos-graal-maven-s2i/s2i/assemble index ebfe3848e4517..3c3e86faf5132 100644 --- a/docker/centos-graal-maven-s2i/s2i/assemble +++ b/docker/centos-graal-maven-s2i/s2i/assemble @@ -7,6 +7,8 @@ set -ex cd /tmp/src/ -mvn package -Pnative -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true -e -B +mvn package -Pnative -e -B \ + -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true \ + -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true cp target/*-runner /quarkus.io/ From 0f5d43109ef017634e8e0b10091982d88b2ef76e Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 10 Mar 2019 13:31:51 +0100 Subject: [PATCH 07/18] restructure GraalVM S2I README sections (clearer like this) --- docker/centos-graal-maven-s2i/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md index a9dc39a551db6..c8b2579cd5882 100644 --- a/docker/centos-graal-maven-s2i/README.md +++ b/docker/centos-graal-maven-s2i/README.md @@ -1,25 +1,25 @@ -# [Quarkus.io](http://quarkus.io) native S2I +# [Quarkus.io](http://quarkus.io) GraalVM Native S2I -## How to build this S2I builder image +## OpenShift -### OpenShift +### OpenShift Build oc new-build https://github.com/quarkusio/quarkus.git --context-dir=docker/centos-graal-maven-s2i --name quarkus-native-s2i -### Locally - - docker build . -t quarkus-native-s2i - -## How to use this - -### OpenShift +### OpenShift Use oc new-app quarkus-native-s2i~https://github.com/quarkusio/quarkus-quickstarts --context-dir=getting-started-native --name=getting-started-native Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds, and you therefore may need to increase the quota for OpenShift's S2I builder containers. -### Locally +## Locally (only for testing) + +### Local Build + + docker build . -t quarkus-native-s2i + +### Local use sudo dnf install source-to-image From 2f3e547cf6743f9faac5b5480ab595997602d162 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 21:32:22 +0100 Subject: [PATCH 08/18] minor centos-graal-maven-s2i README update --- docker/centos-graal-maven-s2i/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md index c8b2579cd5882..a1dfc754140fe 100644 --- a/docker/centos-graal-maven-s2i/README.md +++ b/docker/centos-graal-maven-s2i/README.md @@ -5,10 +5,13 @@ ### OpenShift Build oc new-build https://github.com/quarkusio/quarkus.git --context-dir=docker/centos-graal-maven-s2i --name quarkus-native-s2i + oc logs -f bc/quarkus-native-s2i ### OpenShift Use - oc new-app quarkus-native-s2i~https://github.com/quarkusio/quarkus-quickstarts --context-dir=getting-started-native --name=getting-started-native + oc new-app quarkus-native-s2i~https://github.com/quarkusio/quarkus-quickstarts --context-dir=getting-started --name=getting-started-native + oc logs -f bc/getting-started-native + oc expose svc/getting-started-native Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds, and you therefore may need to increase the quota for OpenShift's S2I builder containers. From 326b8b85ddcd1b5cb4e8ef0cab2dbab30294de92 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 22:27:23 +0100 Subject: [PATCH 09/18] add 'USER 1001' in centos-graal-maven-s2i/Dockerfile This should fix this S2I build error seen on OpenShift: build error: image "..." must specify a user that is numeric and within the range of allowed users --- docker/centos-graal-maven-s2i/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index 7da5f1987c6c3..66c1480620ff0 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -48,7 +48,11 @@ ADD README.md /usr/local/s2i/usage.txt ENV PATH=$PATH:"/usr/local/s2i" -RUN mkdir /quarkus.io/ +RUN adduser -u 1001 -g 0 quarkus --home-dir /quarkus.io/ && \ + chown -R 1001:0 /quarkus.io && \ + chown -R 1001:0 $HOME && \ + chmod -R ug+rwX /quarkus.io +USER 1001 EXPOSE 8080 From 33e95b863b19ed3e84752531385c42a31b7ff2f2 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 22:42:36 +0100 Subject: [PATCH 10/18] use 'cp -v' in s2i/assemble --- docker/centos-graal-maven-s2i/s2i/assemble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/s2i/assemble b/docker/centos-graal-maven-s2i/s2i/assemble index 3c3e86faf5132..f14bba8d7fed6 100644 --- a/docker/centos-graal-maven-s2i/s2i/assemble +++ b/docker/centos-graal-maven-s2i/s2i/assemble @@ -10,5 +10,5 @@ cd /tmp/src/ mvn package -Pnative -e -B \ -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true \ -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true -cp target/*-runner /quarkus.io/ +cp -v target/*-runner /quarkus.io/ From cb2551054219f7e5178d4368bcf61aa67c33d054 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:04:17 +0100 Subject: [PATCH 11/18] improve centos-graal-maven-s2i README --- docker/centos-graal-maven-s2i/README.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md index a1dfc754140fe..d2ae136742da5 100644 --- a/docker/centos-graal-maven-s2i/README.md +++ b/docker/centos-graal-maven-s2i/README.md @@ -2,6 +2,13 @@ ## OpenShift +### Minishift 8 GB Set-Up recommendation + + minishift profile delete quarkus-s2i-native + minishift profile set quarkus-s2i-native + minishift config set memory 8192 + minishift start + ### OpenShift Build oc new-build https://github.com/quarkusio/quarkus.git --context-dir=docker/centos-graal-maven-s2i --name quarkus-native-s2i @@ -13,8 +20,19 @@ oc logs -f bc/getting-started-native oc expose svc/getting-started-native -Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds, -and you therefore may need to increase the quota for OpenShift's S2I builder containers. +Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds. +[By default, builds are completed by pods using unbound resources, such as memory and CPU](https://docs.openshift.com/container-platform/3.11/dev_guide/builds/advanced_build_operations.html), but note that [your OpenShift Project may have +limit ranges defined](https://docs.openshift.com/container-platform/3.11/admin_guide/limits.html#admin-guide-limits). +You therefore may need to increase at least the memory if not the CPU limit for OpenShift's S2I build containers: + + apiVersion: "v1" + kind: "BuildConfig" + metadata: + name: "getting-started-native" + spec: + resources: + limits: + memory: "4Gi" ## Locally (only for testing) @@ -26,7 +44,7 @@ and you therefore may need to increase the quota for OpenShift's S2I builder con sudo dnf install source-to-image - s2i build --copy ../../../quarkus-quickstarts/getting-started-native quarkus-native-s2i getting-started-native + s2i build --copy ../../../quarkus-quickstarts/getting-started quarkus-native-s2i getting-started-native docker run --rm -it -p 8080:8080 getting-started-native From c6f093cf30ada0582c2e44b59e32be47b6afff10 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:15:20 +0100 Subject: [PATCH 12/18] bump GRAAL_VERSION rc12 to rc13 --- docker/centos-graal-maven-s2i/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index 66c1480620ff0..efd6a99b57af8 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -5,7 +5,7 @@ FROM centos:latest ARG GRAAL_VERSION -ENV GRAAL_VERSION=${GRAAL_VERSION:-1.0.0-rc12} +ENV GRAAL_VERSION=${GRAAL_VERSION:-1.0.0-rc13} ARG MAVEN_VERSION=3.6.0 ENV GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz From c165b1c2e5b7f0eaf9b4bb2cdbe345936c8dc610 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:18:17 +0100 Subject: [PATCH 13/18] use ARG instead of ENV in Dockerfile --- docker/centos-graal-maven-s2i/Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index efd6a99b57af8..87abcc9f4decb 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -4,16 +4,15 @@ # This part is heavily inspired by ../centos-graal/Dockerfile FROM centos:latest -ARG GRAAL_VERSION -ENV GRAAL_VERSION=${GRAAL_VERSION:-1.0.0-rc13} +ARG GRAAL_VERSION=1.0.0-rc13 ARG MAVEN_VERSION=3.6.0 -ENV GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz -ENV MAVEN_URL=https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz +ARG GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz +ARG MAVEN_URL=https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -ENV JAVA_HOME=/opt/graalvm -ENV PATH=$PATH:$JAVA_HOME/bin -ENV GRAALVM_HOME=/opt/graalvm +ARG JAVA_HOME=/opt/graalvm +ARG PATH=$PATH:$JAVA_HOME/bin +ARG GRAALVM_HOME=/opt/graalvm RUN yum update -y && \ yum install -y --setopt=skip_missing_names_on_install=False \ From 7c1430576a9106bb0ffbdf22af6b3e9092bf20fd Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:20:11 +0100 Subject: [PATCH 14/18] move add user up, and use home dir in MAVEN_CONFIG --- docker/centos-graal-maven-s2i/Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index 87abcc9f4decb..f1bb8c9306667 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -25,10 +25,15 @@ RUN yum update -y && \ mkdir -p /usr/share/maven && \ curl -fsSL ${MAVEN_URL} | tar -xzC /usr/share/maven --strip-components=1 && \ - ln -s /usr/share/maven/bin/mvn /usr/bin/mvn + ln -s /usr/share/maven/bin/mvn /usr/bin/mvn && \ + + adduser -u 1001 -g 0 quarkus --home-dir /quarkus.io/ && \ + chown -R 1001:0 /quarkus.io && \ + chown -R 1001:0 $HOME && \ + chmod -R ug+rwX /quarkus.io ENV MAVEN_HOME /usr/share/maven -ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2" +ENV MAVEN_CONFIG "/quarkus.io/.m2" ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1" # This part is firmly inspired by fabric8io-images/s2i @@ -47,10 +52,6 @@ ADD README.md /usr/local/s2i/usage.txt ENV PATH=$PATH:"/usr/local/s2i" -RUN adduser -u 1001 -g 0 quarkus --home-dir /quarkus.io/ && \ - chown -R 1001:0 /quarkus.io && \ - chown -R 1001:0 $HOME && \ - chmod -R ug+rwX /quarkus.io USER 1001 EXPOSE 8080 From 4b550da953047136df37fef398f0c91ba16d1716 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:36:28 +0100 Subject: [PATCH 15/18] use /home/quarkus instead of /quarkus.io --- docker/centos-graal-maven-s2i/Dockerfile | 11 ++++++----- docker/centos-graal-maven-s2i/s2i/assemble | 2 +- docker/centos-graal-maven-s2i/s2i/run | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index f1bb8c9306667..c539d14a3a280 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -13,6 +13,8 @@ ARG MAVEN_URL=https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binar ARG JAVA_HOME=/opt/graalvm ARG PATH=$PATH:$JAVA_HOME/bin ARG GRAALVM_HOME=/opt/graalvm +# NB: Also hard-coded in s2i/assemble & s2i/run +ARG QUARKUS_HOME=/home/quarkus/ RUN yum update -y && \ yum install -y --setopt=skip_missing_names_on_install=False \ @@ -27,13 +29,12 @@ RUN yum update -y && \ curl -fsSL ${MAVEN_URL} | tar -xzC /usr/share/maven --strip-components=1 && \ ln -s /usr/share/maven/bin/mvn /usr/bin/mvn && \ - adduser -u 1001 -g 0 quarkus --home-dir /quarkus.io/ && \ - chown -R 1001:0 /quarkus.io && \ - chown -R 1001:0 $HOME && \ - chmod -R ug+rwX /quarkus.io + adduser -u 1001 -g 0 quarkus --home-dir ${QUARKUS_HOME} && \ + chown -R 1001:0 ${QUARKUS_HOME} && \ + chmod -R ug+rwX ${QUARKUS_HOME} ENV MAVEN_HOME /usr/share/maven -ENV MAVEN_CONFIG "/quarkus.io/.m2" +ENV MAVEN_CONFIG ${QUARKUS_HOME}/.m2 ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1" # This part is firmly inspired by fabric8io-images/s2i diff --git a/docker/centos-graal-maven-s2i/s2i/assemble b/docker/centos-graal-maven-s2i/s2i/assemble index f14bba8d7fed6..45f74a97286f6 100644 --- a/docker/centos-graal-maven-s2i/s2i/assemble +++ b/docker/centos-graal-maven-s2i/s2i/assemble @@ -10,5 +10,5 @@ cd /tmp/src/ mvn package -Pnative -e -B \ -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true \ -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true -cp -v target/*-runner /quarkus.io/ +cp -v target/*-runner /home/quarkus/ diff --git a/docker/centos-graal-maven-s2i/s2i/run b/docker/centos-graal-maven-s2i/s2i/run index 790d0cbd7dd84..50f5eb1e6f368 100644 --- a/docker/centos-graal-maven-s2i/s2i/run +++ b/docker/centos-graal-maven-s2i/s2i/run @@ -4,4 +4,4 @@ # a TODO future PRODUCTION version of this would probably want tomake it possible to # e.g. pass additional parameters to the executable, as does fabric8io-images/s2i's run script. -/quarkus.io/*-runner -Dquarkus.http.host=0.0.0.0 +/home/quarkus/*-runner -Dquarkus.http.host=0.0.0.0 From 04029d9684d4e46ce9d384276df50f36c3245502 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Mar 2019 23:41:58 +0100 Subject: [PATCH 16/18] use ENV instead of ARG in Dockerfile where appropriate --- docker/centos-graal-maven-s2i/Dockerfile | 9 ++++----- docker/centos-graal-maven-s2i/s2i/assemble | 2 +- docker/centos-graal-maven-s2i/s2i/run | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docker/centos-graal-maven-s2i/Dockerfile b/docker/centos-graal-maven-s2i/Dockerfile index c539d14a3a280..d24acd39ec711 100644 --- a/docker/centos-graal-maven-s2i/Dockerfile +++ b/docker/centos-graal-maven-s2i/Dockerfile @@ -10,11 +10,10 @@ ARG MAVEN_VERSION=3.6.0 ARG GRAAL_CE_URL=https://github.com/oracle/graal/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-${GRAAL_VERSION}-linux-amd64.tar.gz ARG MAVEN_URL=https://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz -ARG JAVA_HOME=/opt/graalvm -ARG PATH=$PATH:$JAVA_HOME/bin -ARG GRAALVM_HOME=/opt/graalvm -# NB: Also hard-coded in s2i/assemble & s2i/run -ARG QUARKUS_HOME=/home/quarkus/ +ENV JAVA_HOME=/opt/graalvm +ENV PATH=$PATH:$JAVA_HOME/bin +ENV GRAALVM_HOME=/opt/graalvm +ENV QUARKUS_HOME=/home/quarkus RUN yum update -y && \ yum install -y --setopt=skip_missing_names_on_install=False \ diff --git a/docker/centos-graal-maven-s2i/s2i/assemble b/docker/centos-graal-maven-s2i/s2i/assemble index 45f74a97286f6..749398714d71c 100644 --- a/docker/centos-graal-maven-s2i/s2i/assemble +++ b/docker/centos-graal-maven-s2i/s2i/assemble @@ -10,5 +10,5 @@ cd /tmp/src/ mvn package -Pnative -e -B \ -DskipTests -Dmaven.javadoc.skip=true -Dmaven.site.skip=true -Dmaven.source.skip=true \ -Djacoco.skip=true -Dcheckstyle.skip=true -Dfindbugs.skip=true -Dpmd.skip=true -Dfabric8.skip=true -cp -v target/*-runner /home/quarkus/ +cp -v target/*-runner ${QUARKUS_HOME} diff --git a/docker/centos-graal-maven-s2i/s2i/run b/docker/centos-graal-maven-s2i/s2i/run index 50f5eb1e6f368..3210c6cc433a9 100644 --- a/docker/centos-graal-maven-s2i/s2i/run +++ b/docker/centos-graal-maven-s2i/s2i/run @@ -4,4 +4,4 @@ # a TODO future PRODUCTION version of this would probably want tomake it possible to # e.g. pass additional parameters to the executable, as does fabric8io-images/s2i's run script. -/home/quarkus/*-runner -Dquarkus.http.host=0.0.0.0 +${QUARKUS_HOME}/*-runner -Dquarkus.http.host=0.0.0.0 From a05b6f3a821217d1b4a1e98e635a271e4ab4bc83 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 19 Mar 2019 14:03:53 +0100 Subject: [PATCH 17/18] update Native S2I README with testing results re. CPU limit --- docker/centos-graal-maven-s2i/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md index d2ae136742da5..0f640c9b1ae09 100644 --- a/docker/centos-graal-maven-s2i/README.md +++ b/docker/centos-graal-maven-s2i/README.md @@ -21,9 +21,10 @@ oc expose svc/getting-started-native Note that GraalVM-based native build are more memory & CPU intensive than regular pure Java builds. -[By default, builds are completed by pods using unbound resources, such as memory and CPU](https://docs.openshift.com/container-platform/3.11/dev_guide/builds/advanced_build_operations.html), but note that [your OpenShift Project may have -limit ranges defined](https://docs.openshift.com/container-platform/3.11/admin_guide/limits.html#admin-guide-limits). -You therefore may need to increase at least the memory if not the CPU limit for OpenShift's S2I build containers: +[By default, builds are completed by pods using unbound resources, such as memory and CPU](https://docs.openshift.com/container-platform/3.11/dev_guide/builds/advanced_build_operations.html), +but note that [your OpenShift Project may have limit ranges defined](https://docs.openshift.com/container-platform/3.11/admin_guide/limits.html#admin-guide-limits). + +Testing indicates that the "hello, world" getting-started demo application builds in around 2 minutes on typical hardware when the build is given 4 GB of RAM and 4 (virtual) CPUs for concurrency. You therefore may need to increase the respective limits for OpenShift's S2I build containers like so: apiVersion: "v1" kind: "BuildConfig" @@ -32,7 +33,8 @@ You therefore may need to increase at least the memory if not the CPU limit for spec: resources: limits: - memory: "4Gi" + cpu: '4' + memory: 4Gi ## Locally (only for testing) From fafe896a81cf6066b8d48407c386a09eacbdf486 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 19 Mar 2019 17:37:36 +0100 Subject: [PATCH 18/18] add 'oc patch' tip to Native S2I README (tx @tqvarnst) --- docker/centos-graal-maven-s2i/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/centos-graal-maven-s2i/README.md b/docker/centos-graal-maven-s2i/README.md index 0f640c9b1ae09..19bccf0377f9f 100644 --- a/docker/centos-graal-maven-s2i/README.md +++ b/docker/centos-graal-maven-s2i/README.md @@ -36,6 +36,10 @@ Testing indicates that the "hello, world" getting-started demo application build cpu: '4' memory: 4Gi +The following `oc patch` command does this: + + oc patch bc/getting-started-native -p '{"spec":{"resources":{"limits":{"cpu":"4", "memory":"4Gi"}}}}' + ## Locally (only for testing) ### Local Build