-->

mercredi 28 décembre 2016

Send hipchat notification from Jenkins pipeline

Introduction :

For a few months I have been working on automating the deployment of web executables on docker containers hosted on AMAZON AWS, and I have added a hipchat notification to each deployment.

mardi 27 décembre 2016

Docker : how to create Wildfly and MySQL in the same server

Introduction :

I continue with the exploration of the docker world. After wildfly container creation, i will add a MySQL RDMBS, for this you have the choice between the creation of two Dockerfile document and execute the build and the run of servers, or, write in once only one document and specify the environnement document in the whole.

Let's code now the first choice :

the Dockerfile for Wildfly  


The wildfly dockerfile file mentions several other files such as standalone-mjhazbri.xml and module-mysql.xm. The file start-wildfly.sh will be used to start the server wildfly :
  


The Dockerfile of MySQL : 



The MySQL dockerfile file mentions several other files such as my.cnf and run.sh :


the second choice will be explained in other article.

mercredi 21 décembre 2016

Install Wildfly with Docker

Introduction :

Recently, for a mission to a client, my team and I had developed a backoffice application to expose web services REST. We used the Java EE 7 standard. Among several application servers we chose Wildlfy 9. And so I was able to install this server for continuous integration.

Introduction :

As stated in my old article, the docker's heart is the Dockerfile file, so the first thing to do is to write this file.


FROM jboss/wildfly:9.0.2.Final
MAINTAINER Jalel HAZBRI "jalel.hazbri@gmail.com"

# ENV VARIABLES 
ENV WILDFLY_HOME /opt/jboss/wildfly
ENV WILDFLY_VERSION 9.0.2.Final

# Add console admin user
RUN ${WILDFLY_HOME}/bin/add-user.sh mjhazbri mjhazbri --silent

# Ports
EXPOSE 8080 9990

# Volumes
VOLUME ${WILDFLY_HOME}/standalone/deployments/
VOLUME ${WILDFLY_HOME}/standalone/log/

# RUN script
COPY start-wildfly.sh ${WILDFLY_HOME}/bin/start-wildfly.sh
USER root
RUN chmod +x ${WILDFLY_HOME}/bin/start-wildfly.sh
#USER jboss

ENTRYPOINT ["sh", "-c", "${WILDFLY_HOME}/bin/start-wildfly.sh"]

And the last line is to start wildfly with the script start-wildfly.sh :

#!/bin/sh

${WILDFLY_HOME}/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0




mardi 20 décembre 2016

Docker : Dockerfile

Introduction :

First, to Dockerfile, we should read this definition extracted from docker web site : 
"Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession."

Second, the Dockerfile has this format :  


# Comment
INSTRUCTION arguments

From :

The instruction is not case-sensitive. However, convention is for them to be UPPERCASE to distinguish them from arguments more easily. Docker runs instructions in a Dockerfile in order. The first instruction must be `FROM` in order to specify the Base Image from which you are building.

FROM ImageName
# directive=value

The FROM structure is :


FROM image

Or 


FROM image:tag

Or 


FROM image@digest

From :

The Maintainer instruction allows you to set the Author field of the generated images.

Expose :

The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. EXPOSE does not make the ports of the container accessible to the host. To do that, you must use either the -pflag to publish a range of ports or the -P flag to publish all of the exposed ports. You can expose one port number and publish it externally under another number.

ENV:

The The ENV instruction sets the environment variable to the value . This value will be in the environment of all “descendant” Dockerfile commands and can be replaced inline in many as well.

The ENV instruction has two forms. The first form, ENV , will set a single variable to a value. The entire string after the first space will be treated as the - including characters such as spaces and quotes.

The second form, ENV = ..., allows for multiple variables to be set at one time. Notice that the second form uses the equals sign (=) in the syntax, while the first form does not. Like command line parsing, quotes and backslashes can be used to include spaces within values.


ENV JAVA_HOME /dir_to_java

ADD:

The ADD has two forms:


ADD "src"... "dest"
ADD ["src",... "dest"] (this form is required for paths containing whitespace)

The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the path .

Multiple resource may be specified but if they are files or directories then they must be relative to the source directory that is being built (the context of the build).


ADD test relativeDir/          # adds "test" to `WORKDIR`/relativeDir/
ADD test /absoluteDir/         # adds "test" to /absoluteDir/

COPY:

The COPY has two forms:


COPY "src"... "dest
COPY ["src",... "dest"] (this form is required for paths containing whitespace)

The COPY instruction copies new files or directories from and adds them to the filesystem of the container at the path .

Multiple resource may be specified but they must be relative to the source directory that is being built (the context of the build).


COPY test relativeDir/   # adds "test" to `WORKDIR`/relativeDir/
COPY test /absoluteDir/  # adds "test" to /absoluteDir/