
Build a legacy software with docker
Following the rework of a legacy application in GWT for a client, we encountered problems during compilation. Indeed it required the installation of old libraries not available on the current environments of the developers.
The idea was therefore to provide a functional compilation solution on any environment :
developer workstation
client workstation
development / integration server
For that purpose we have decided to use docker. We created a docker image from a maven image, on which we downloaded the GWT libraries necessary for the compilation of the project.
Which gives the following Dockerfile :
::: formalpara-title Dockerfile.build :::
FROM maven:3.6-jdk-7
WORKDIR /var
RUN curl https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-web-toolkit/gwt-linux-1.5.3.tar.bz2 | tar xjf -
Then we created a script to start the compilation :
::: formalpara-title build-with-docker.sh :::
docker build -t mvn-gwt -f Dockerfile.build .
docker run \
-v ~/.m2:/var/maven/.m2 \
-v "$PWD":/usr/local/src/ \
-w /usr/local/src/ \
-ti --rm -u $(id -u) \
-e MAVEN_CONFIG=/var/maven/.m2 \
mvn-gwt \
mvn -Duser.home=/var/maven -Dgoogle.webtoolkit.home=/var/gwt-linux-1.5.3 $1
From this script the compilation of the project can be started from any environment by simply running the command :
./build-with-docker.sh <target_maven>