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

Native S2I Builder image #1358

Merged
merged 19 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
86a6c94
add Native S2I Builder image v0.1 (#304)
vorburger Mar 8, 2019
d971989
add 'EXPOSE 8080' to native S2I builder Dockerfile
vorburger Mar 8, 2019
0f677d6
Minor label spelling update docker/centos-graal-maven-s2i/Dockerfile
gastaldi Mar 8, 2019
43cd78b
use better Maven DL URL in Native S2I Dockerfile
gastaldi Mar 8, 2019
335cdfb
improve graal-maven-s2i Dockerfile io.k8s.* LABELs
vorburger Mar 10, 2019
9fb4604
move -e -B in GraalVM S2I assemble script (and multiline)
vorburger Mar 10, 2019
0f5d431
restructure GraalVM S2I README sections (clearer like this)
vorburger Mar 10, 2019
2f3e547
minor centos-graal-maven-s2i README update
vorburger Mar 18, 2019
326b8b8
add 'USER 1001' in centos-graal-maven-s2i/Dockerfile
vorburger Mar 18, 2019
33e95b8
use 'cp -v' in s2i/assemble
vorburger Mar 18, 2019
cb25510
improve centos-graal-maven-s2i README
vorburger Mar 18, 2019
387df05
Merge branch 'master' into issue-304_s2i-native-DEV
vorburger Mar 18, 2019
c6f093c
bump GRAAL_VERSION rc12 to rc13
vorburger Mar 18, 2019
c165b1c
use ARG instead of ENV in Dockerfile
vorburger Mar 18, 2019
7c14305
move add user up, and use home dir in MAVEN_CONFIG
vorburger Mar 18, 2019
4b550da
use /home/quarkus instead of /quarkus.io
vorburger Mar 18, 2019
04029d9
use ENV instead of ARG in Dockerfile where appropriate
vorburger Mar 18, 2019
a05b6f3
update Native S2I README with testing results re. CPU limit
vorburger Mar 19, 2019
fafe896
add 'oc patch' tip to Native S2I README (tx @tqvarnst)
vorburger Mar 19, 2019
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
61 changes: 61 additions & 0 deletions docker/centos-graal-maven-s2i/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# [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
cescoffier marked this conversation as resolved.
Show resolved Hide resolved

ARG GRAAL_VERSION=1.0.0-rc13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we would need to have a way to easily remember to update this every time we are working on updating to the latest GraalVM version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@geoand geoand Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ARG MAVEN_VERSION=3.6.0
cescoffier marked this conversation as resolved.
Show resolved Hide resolved

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
ENV QUARKUS_HOME=/home/quarkus

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 && \

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_HOME}/.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="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
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"

USER 1001

EXPOSE 8080
cescoffier marked this conversation as resolved.
Show resolved Hide resolved

# 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" ]
51 changes: 51 additions & 0 deletions docker/centos-graal-maven-s2i/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# [Quarkus.io](http://quarkus.io) GraalVM Native S2I

## 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
cescoffier marked this conversation as resolved.
Show resolved Hide resolved
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 --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.
[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)

### Local Build

docker build . -t quarkus-native-s2i

### Local use

sudo dnf install source-to-image

s2i build --copy ../../../quarkus-quickstarts/getting-started quarkus-native-s2i getting-started-native

docker run --rm -it -p 8080:8080 getting-started-native

curl http://localhost:8080/hello/greeting/quarkus
14 changes: 14 additions & 0 deletions docker/centos-graal-maven-s2i/s2i/assemble
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/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 -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_HOME}

7 changes: 7 additions & 0 deletions docker/centos-graal-maven-s2i/s2i/run
Original file line number Diff line number Diff line change
@@ -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_HOME}/*-runner -Dquarkus.http.host=0.0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Dquarkus.http.host=0.0.0.0 shouldn't be needed anymore since it's now the default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is that already released, right now? I would prefer to keep this and then see it removed a while after a new release, together with more generally cleaning this up in many places where it currently still appears.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is in master and will be present in the 0.12.0 release that I think @cescoffier will be doing tomorrow.
I'll leave it up to you to best decide how to handle this :)

Copy link
Contributor

@geoand geoand Mar 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should keep it based on this #1312 (comment)