Coder Social home page Coder Social logo

adambien / docklands Goto Github PK

View Code? Open in Web Editor NEW
323.0 55.0 107.0 283 KB

Minimalistic Java EE / Jakarta EE / MicroProfile Related Dockerfiles

License: Apache License 2.0

JavaScript 11.92% Shell 19.28% VCL 2.11% Dockerfile 66.69%
docker cloud payara wildfly microservices dockerfile glassfish tomee openliberty openshift

docklands's Introduction

docklands

Minimalistic Java EE Dockerfiles

Motivation

Simplest viable dockerfiles for Java EE projects (aka microservices) aiming for build speed and productivity.

Usage

Each folder represents a Dockerfile which can be build by executing the build.js command. Recent builds already exist in https://hub.docker.com/u/airhacks/. To run the image use the "airhacks" name e.g. docker run -d -p 8080:8080 --name payara-ping airhacks/payara-ping.

You can either make the build.js executable or run it with jjs -scripting build.js

Some images are executable. You will find a run.sh script in this case.

Heavily used in javaeemicro.services

Docklands was used in the screencast: "The Memory Usage of Java EE 7 Application Servers Running On Docker":

The Memory Usage of Java EE 7 Application Servers Running On Docker

Docklands projects are also directly available from the official docker hub: https://hub.docker.com/u/airhacks/

docklands's People

Contributors

adambien avatar brunoborges avatar mcpringle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docklands's Issues

airhacks/glassfish:v5 and airhacks/glassfish:5.1.0 are broken for https external calls

The containers published on docker hub airhacks/glassfish:v5 and airhacks/glassfish:5.1.0 use openjdk version "1.8.0_121" generating the following error when you try to call an external RESTFull service through HTTPs:

Caused by: java.lang.NoClassDefFoundError: sun/security/ssl/HandshakeStateManager
at sun.security.ssl.Handshaker.init(Handshaker.java:282)
at sun.security.ssl.Handshaker.(Handshaker.java:242)
at sun.security.ssl.ClientHandshaker.(ClientHandshaker.java:160)
at sun.security.ssl.SSLSocketImpl.initHandshaker(SSLSocketImpl.java:1329)
at sun.security.ssl.SSLSocketImpl.doneConnect(SSLSocketImpl.java:690)
at sun.security.ssl.SSLSocketImpl.(SSLSocketImpl.java:569)
at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:365)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)

An easy fix is publishing the Glassfish image with a new jdk version, for instance:

FROM airhacks/java-s2i
ENV GLASSFISH_ARCHIVE glassfish5
ENV DOMAIN_NAME domain1
ENV INSTALL_DIR /opt
RUN useradd -b /opt -m -s /bin/sh -d ${INSTALL_DIR} serveradmin && echo serveradmin:serveradmin | chpasswd
RUN curl -o ${INSTALL_DIR}/${GLASSFISH_ARCHIVE}.zip -L http://mirrors.xmission.com/eclipse/glassfish/glassfish-5.1.0.zip \
&& unzip ${INSTALL_DIR}/${GLASSFISH_ARCHIVE}.zip -d ${INSTALL_DIR} \
&& rm ${INSTALL_DIR}/${GLASSFISH_ARCHIVE}.zip
&& chown -R serveradmin:serveradmin /opt
&& chmod -R a+rw /opt
ENV GLASSFISH_HOME ${INSTALL_DIR}/${GLASSFISH_ARCHIVE}/glassfish
ENV DEPLOYMENT_DIR ${GLASSFISH_HOME}/domains/domain1/autodeploy
WORKDIR ${GLASSFISH_HOME}/bin
USER serveradmin
EXPOSE 4848 8009 8080 8181

airhacks/java-s2i uses openjdk version "1.8.0_191" where HTTPs works fine.

Can't run Wildfly image on openshift

Openshift v3 accepts a docker image from docker hub (see example here) but when I use "airhacks/wildfly" I got the following error when the container starts on openshift:


=========================================================================
--
  |  
  | JBoss Bootstrap Environment
  |  
  | JBOSS_HOME: /opt/wildfly-10.1.0.Final
  |  
  | JAVA: /usr/lib/jvm/java-1.8.0/bin/java
  |  
  | JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
  |  
  | =========================================================================
  |  
  | java.lang.IllegalArgumentException: Failed to instantiate class "org.jboss.logmanager.handlers.PeriodicRotatingFileHandler" for handler "FILE"
  | at org.jboss.logmanager.config.AbstractPropertyConfiguration$ConstructAction.validate(AbstractPropertyConfiguration.java:116)
  | at org.jboss.logmanager.config.LogContextConfigurationImpl.doPrepare(LogContextConfigurationImpl.java:335)
  | at org.jboss.logmanager.config.LogContextConfigurationImpl.prepare(LogContextConfigurationImpl.java:288)
  | at org.jboss.logmanager.config.LogContextConfigurationImpl.commit(LogContextConfigurationImpl.java:297)
  | at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:546)
  | at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:97)
  | at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:514)
  | at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:476)
  | at java.util.logging.LogManager$3.run(LogManager.java:399)
  | at java.util.logging.LogManager$3.run(LogManager.java:396)
  | at java.security.AccessController.doPrivileged(Native Method)
  | at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:396)
  | at java.util.logging.LogManager.access$800(LogManager.java:145)
  | at java.util.logging.LogManager$2.run(LogManager.java:345)
  | at java.security.AccessController.doPrivileged(Native Method)
  | at java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:338)
  | at java.util.logging.LogManager.getLogManager(LogManager.java:378)
  | at org.jboss.modules.Main.main(Main.java:480)
  | Caused by: java.lang.reflect.InvocationTargetException
  | at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  | at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  | at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  | at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  | at org.jboss.logmanager.config.AbstractPropertyConfiguration$ConstructAction.validate(AbstractPropertyConfiguration.java:114)
  | ... 17 more
  | Caused by: java.io.FileNotFoundException: /opt/wildfly-10.1.0.Final/standalone/log/server.log (No such file or directory)
  | at java.io.FileOutputStream.open0(Native Method)
  | at java.io.FileOutputStream.open(FileOutputStream.java:270)
  | at java.io.FileOutputStream.<init>(FileOutputStream.java:213)

I've made a fast research and found this issue on official wildfly image repository:

jboss-dockerfiles/wildfly#25

Payara Docker image improvement with Payara Server 172

The ENTRYPOINT in payara/Dockerfile can be improved with the new --postbootcommandfile argument of the start-domain command, so that the Payara Server can be executed in the foreground as the main Docker process.

ENTRYPOINT echo deploy ${DEPLOYMENT_DIR}/${WAR} > deploy-command && \
           asadmin start-domain --verbose --postbootcommandfile deploy-command ${DOMAIN_NAME}

A more complex command to support deployment of all apps in a directory is used in the official Payara Docker Dockerfile and images hosted in the Docker hub

It does not make a lot of sense to expose port 4848 of glassfish if secure admin is not enabled

I just used your java ee 8 essential archetype from maven and it is awesome.

When I tried to access http://localhost:4848 the following was shown:

Error Configuration Error
Secure Admin must be enabled to access the DAS remotely.

image

After some googling I found:

https://github.com/glassfish/docker/blob/master/nightly/Dockerfile from @brunoborges

I adapted the archtetype Dockerfile:

FROM airhacks/glassfish
# Comment in these lines to set the password to changeme and the admin interface to SSL. This is required to access https://localhost:4848/
#RUN asadmin --user=admin stop-domain && \
#    echo "--- Setup the password file ---" && \
#    echo "AS_ADMIN_PASSWORD=" > /tmp/glassfishpwd && \
#    echo "AS_ADMIN_NEWPASSWORD=changeme" >> /tmp/glassfishpwd  && \
#    echo "--- Enable DAS, change admin password, and secure admin access ---" && \
#    asadmin --user=admin --passwordfile=/tmp/glassfishpwd change-admin-password && \
#    asadmin start-domain && \
#    echo "AS_ADMIN_PASSWORD=changeme" > /tmp/glassfishpwd && \
#    asadmin --user=admin --passwordfile=/tmp/glassfishpwd enable-secure-admin && \
#    asadmin --user=admin stop-domain && \
#    asadmin start-domain --verbose && \
#    rm /tmp/glassfishpwd
COPY ./target/mywarfile.war ${DEPLOYMENT_DIR}

It would be nice if this template can be added to your glassfish Dockerfile as well.

/Manuel

Wildfly 12

Currently supports wildfly 11. Wildfly 12 is available and should be supported too.

Use 'glassfish/openjdk', or be inspire by it

Instead of using CentOS base image, consider using glassfish/openjdk (or produce something similar). It is published on Docker Hub and is based on Alpine Linux. It is very minimalistic, very small, and still 100% functional.

Reduce your Wildfly Docker image

Adam you can reduce your wildfly docker image by deleting the downloaded zip file. This will bring it closer to the Ubuntu IBM JRE WLP image size of 421M.

FROM airhacks/java
MAINTAINER Adam Bien, adam-bien.com
ENV VERSION wildfly-10.0.0.Final
ENV INSTALL_DIR /opt
ENV WILDFLY_HOME ${INSTALL_DIR}/${VERSION}
ENV DEPLOYMENT_DIR ${WILDFLY_HOME}/standalone/deployments/
RUN curl -O https://download.jboss.org/wildfly/10.0.0.Final/${VERSION}.zip
&& unzip ${VERSION}.zip -d ${INSTALL_DIR}
&& rm ${WILDFLY_HOME}/bin/standalone.conf
&& rm ${VERSION}.zip
ADD standalone.conf ${WILDFLY_HOME}/bin/
RUN chmod a+x ${WILDFLY_HOME}/bin/standalone.sh
ENTRYPOINT ${WILDFLY_HOME}/bin/standalone.sh -b=0.0.0.0
EXPOSE 8080

Toms-MBP:ibmjavaubuntu tjmcmanus$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cent-wildfly-ping latest 44865f2731cd 14 minutes ago 560.3 MB
cent-wlp-ping latest 347a83260e38 16 minutes ago 516.4 MB
cent-wildfly-ping latest a10651690c7d 38 minutes ago 698.5 MB
ubunt-wlp-full-ping latest bcf4201c9c17 42 minutes ago 469.9 MB
ubunt-wlp-ping latest 81a2e706255d 48 minutes ago 421.3 MB
cent-java latest ab3a030127f7 20 hours ago 399.4 MB
centos 7 05188b417f30 20 days ago 196.8 MB
ubuntu-ibmjre latest aba6ccca9224 20 hours ago 304.9 MB
ubuntu 16.04 cf62323fa025 7 days ago 125 MB
ubuntu latest cf62323fa025 7 days ago 125 MB

Eclipse Glassfish

Eclipse Glassfish is close to making their first release: https://blogs.eclipse.org/post/tanja-obradovic/announcing-eclipse-glassfish-510-rc1-release

That blog post says, "the RC1 gives the community an opportunity to test the code and provide their feedback." However, some of want to test the release candidate in Docker and if Docker images are part of the release candidate, I have been unable to find them. This issue seems to be the one to track: eclipse-ee4j/glassfish#22598

@AdamBien how do you feel about creating Docker images for Eclipse Glassfish 5.1 RC1 and pushing them to https://hub.docker.com/u/airhacks/ ? Good idea? Bad idea? 😄

airhacks/payara start.sh not in sync with Docker Hub

Docker hub seems to have a wrong version of the start.sh script which does not point to the correct deployment folder.

After docker pull airhacks/payara from inside the container:

[root@bc0de921e222 bin]# cat start.sh
#!/bin/sh
echo deploy `cd ${DEPLOYMENT_DIR} && ls -1 | head -1` > deploy-command
cat deploy-command
asadmin start-domain --verbose --postbootcommandfile deploy-command ${DOMAIN_NAME}

This does not match the start.sh from this repository and leads to failed deployment.
More precisely the script is missing the ${DEPLOYMENT_DIR}/ part.

Wildfly image

I'm new to docker and just started to experiment with docker. Therefor I used the docklands wildfly image. Starting wildfly with an ENTRYPOINT causes the image to not react on image shutdownhook and the wildfly ist just killed.

From the docker reference:

The shell form prevents any CMD or run command line arguments from being used, but has the disadvantage that your ENTRYPOINT will be started as a subcommand of /bin/sh -c, which does not pass signals. This means that the executable will not be the container’s PID 1 - and will not receive Unix signals - so your executable will not receive a SIGTERM from docker stop .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.