fabric8io-images / java

Java Base Images
Apache License 2.0
176 stars 99 forks source link

OpenShift start build failing expecting a numeric user value #46

Open imranzunzani opened 5 years ago

imranzunzani commented 5 years ago

On OpenShift build (binary), the images are generating the following error: 'must specify a user that is numeric and within the range of allowed users'

while the images from:

https://hub.docker.com/r/fabric8/s2i-java

are working fine.

imranzunzani commented 5 years ago

These images are not s2i compatible. As Alpine's jre has the smallest footprint (just jre) and overall image size, I found the following way to run the image:

  1. Created image with Dockerfile:

FROM fabric8/java-alpine-openjdk8-jre:1.6.3

LABEL io.k8s.description="Platform for building and running plain Java applications (fat-jar and flat classpath)" \ io.k8s.display-name="Java Applications" \ io.openshift.tags="builder,alpine-java" \ io.openshift.s2i.scripts-url="image:///usr/local/s2i" \ io.openshift.s2i.destination="/tmp"

ADD s2i /usr/local/s2i

RUN chmod 777 -R /deployments

USER 1001

CMD [ "/deployments/run-java.sh" ]



2. Used the s2i files in the _ADD_ from:
[fabric8io-images](https://github.com/fabric8io-images/s2i/tree/master/java/images/rhel/s2i)

3. Modified the 'run' script to launch '/deployments/run-java.sh' at the end.

The resultant image works with OpenShift's s2i.
rhuss commented 5 years ago

Why don't you just use https://github.com/fabric8io-images/s2i which is the S2I Java Builder image, whereas this image is meant to be as base images which you can tune as you like (e.e. setting an numeric UID) ?

imranzunzani commented 5 years ago

I was looking for an Alpine base, because of the smaller size. The S2I section doesn't has one. I came across this one and it is running pretty sleek and good with the S2I labels and modifications. Could you please include an S2I compatible Alpine one, as that would be really nice to have?

Also, on a different note: The latest JDK/JRE for 8 and above now have the XX:+UseContainerSupport enabled by default which computes the memory (heap) and proc values based on settings for the container. So, the run-java.sh could be simplified and relieved of these calculations. Reference

rhuss commented 5 years ago

This image does not contain and will never contain any S2I scripts. Feel free to open an issue over there at https://github.com/fabric8io-images/s2i for an alpine based image.

Thanks for the heads up wrt/ the updates on the latest JDK. Happy to take PRs to improve the scripts.

imranzunzani commented 5 years ago

I have sent the PR to merge. Please check.