mercredi 5 août 2015

Content of a dockerfile to run glassfish server and deploy specific application from a git repository

I am trying to deploy my java ee application using a glassfish 4.1 server and I would like to deploy it as a Docker container.

As a consequence, I'd like writing a correct docker to download/start a glassfish server and then deploy my application on it, using the corresponding GIT repository.

Currently I am able to build a Docker container starting a glassfish server with the following Dockerfile:

FROM        java:8-jdk

ENV         JAVA_HOME         /usr/lib/jvm/java-8-openjdk-amd64
ENV         GLASSFISH_HOME    /usr/local/glassfish4
ENV         PATH              $PATH:$JAVA_HOME/bin:$GLASSFISH_HOME/bin

RUN         apt-get update && \
            apt-get install -y curl unzip zip inotify-tools && \
            rm -rf /var/lib/apt/lists/*

RUN         curl -L -o /tmp/glassfish-4.1.zip http://ift.tt/1H3E7bq && \
            unzip /tmp/glassfish-4.1.zip -d /usr/local && \
            rm -f /tmp/glassfish-4.1.zip

EXPOSE      8080 4848 8181

WORKDIR     /usr/local/glassfish4

# verbose causes the process to remain in the foreground so that docker can track it
CMD         asadmin start-domain --verbose

Then, I build the Docker container (named 'myglassfish')

docker build -t myglassfish .

Finally, I launch the glassfish on my port 8080 using the following command line:

docker run -d -ti -p 4848:4848 -p 8080:8080 myglassfish

The glassfish server is correctly started because I can see the following information by taping 'localhost:8080' on my browser :

'Your server is now running...' (I cannot display the screenshot)

Now, I would like deploying my web application on that server, ideally using the GIT repository of my project (prefered solution) or a war file export of the application.

How should I modify the previous Dockerfile to load and deploy my application in the Glassfish server before starting it (I specify that I am a noob in linus and command line instructions so please be explicit in your answers)?

Thanks by advance!

Aucun commentaire:

Enregistrer un commentaire