Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Current »

TODO : reorganize the documentation


Starting from Datafari 5

As you can see in the rest of the documentation, you can already develop and debug your Datafari code in a Debian or Ubuntu environment. But in this page we detail how to develop for any environments like MacOS X or Windows thanks to Docker for hosting Datafari. So you develop locally on your PC/Mac and you deploy on Docker to see the changes.

The different steps are :

  • 1.Clone the Datafari code

  • 2. Set up your Eclipse environment

  • 3. Set up your Docker environment :

  • 4. Do some changes and deploy !

Pre-requisites

  • Have a JDK installed on your PC/Mac (Java 11)

  • Have an IDE installed on your PC/Mac (in the guide we use Eclipse)

  • Have Git installed on your PC/Mac

  • Have Maven and Ant installed on your PC/Mac

  • Have Docker installed on your PC/Mac

The first steps are pretty much the same than for a setup on a Linux environment. You can refer to the page for further explanations on the first steps : Setup development environment with Eclipse (Linux) for Datafari 4.x.

1. Clone the Datafari code

Open a terminal and navigate to the folder where you want to have Datafari source code to be checked out (usually your workspace folder).

launch the command :

git clone https://github.com/francelabs/datafari.git

to checkout the code. The root directory name is datafari.

2. Set up your Eclipse environment

Build Datafari for the development environment

Navigate to the folder datafari. We now call it DATAFARI_SRC.

Run in DATAFARI_SRC :

mvn install 


Run in DATAFARI_SRC/linux :

ant

Open the project in Eclipse

In Eclipse,go to File -> Import... , type maven and « Existing Maven project ».

Select the DATAFARI_SRC folder as root directory and click Finish. 

3. Set up your Docker environment

  • Build the Docker image :

cd your_datafari_code_folder

docker build -t datafaridev .

The build should be successful like that :

  • Run the Docker container

Note that we use the bind mount of Docker to be able to take into account the files modified in Eclipse directly in the Docker container.

The syntax of the bind mount is : /your_datafari_code/folder/datafari-webpp/target/Datafari:/var/datafari/webapp

So the command is :

docker run -p 443:443 -p 5601:5601 -ti -v /your_datafari_code/folder/datafari-webpp/target/Datafari:/var/datafari/webapp datafaridev

Explanations :

-p 443:443 -p 5601:5601 : it is the mapping between the ports that you want to expose on the container and the ports that you want to open for this on your PC/Mac to access. The first number is the local port, the second number is the port on the container.
datafaridev : the name of the DOcker image that we build on the previous step

-ti and bash : the parameter -ti and the command bash indicate that we want to launch the container into interactive mode and launch the bash command

If the docker run command is successful, your prompt changed and you are in the /var/datafari folder.


You can now access to the Datafari UI !

Open your browser and access to Datafari in your localhost, the port is the port that you entered in the previous stpe ie 9999.

https://localhost/Datafari

You should see the Datafari front page :


4. Do some changes and deploy

Now that we have a fully functional instance of Datafari in running state, how to deploy changes that we do on Datafari code on Eclipse on the Datafari Docker container ?

Let's do this !

  • Modification on the Java code

In Eclipse, open datafari-webapp project.

Let's say that we want to change the class Synonyms in com.francelabs.datafari.servlets.admin :

We replace the l.117 : 

jsonResponse.put("synonymsList", synonymsList);

by :

jsonResponse.put("HelloDockerDatafari", synonymsList);


Save the file

We launch a maven build on the datafari-webapp project :

On your local PC/Mac :

Go to the folder that contains your Datafari code Then launch :

mvn install -pl datafari-webapp -am


On the Docker container :
Stop Datafari :

cd /opt/datafari/bin

bash stop-datafari.sh


Copy the content of the /var/datafari folder into Datafari installation folder :

cp -r /var/datafari/webapp/* /opt/datafari/tomcat/webapps/Datafari/


Start Datafari :

cd /opt/datafari/bin

bash start-datafari.sh


You should see the change that you made into the developer tools when you access to the Synonyms admin UI :


  • Modification on the UI

If you want to do some basic change on the UI, the previous process is not useful. We can simplify the process.

Let's say that we want to do a change in the Javascript of the synonyms. For this we edit the file synonyms.js located in /your_datafari_code/datafari-webapp/src/main/webapp/ajax/js/synonyms.js

We add an alert at the load of the page :

add the line : 

alert("Hello Docker Datafari !");


after :

$(document).ready(function() {


Save the file.

On your local PC/Mac :

Go to the folder that contains your Datafari code Then launch :

mvn install -pl datafari-webapp -am -DskipTests


On the Docker container :

Copy directly the js folder of the /var/datafari folder into Datafari installation folder :

cp -r /var/datafari/webapp/ajax/* /opt/datafari/tomcat/webapps/Datafari/ajax/

You should see the change that you made into the developer tools when you access to the Synonyms admin UI :

  • Remote debug on Tomcat

TBD




TODO : reorganize the documentation

Starting from Docker 18.09 a new build architecture was developed : BuildKit. 

The build speed of Datafari EE is increased a lot thanks to that. Only 3 min for a build with Java code modification and only 1 minute if no Java code modified.

To do so new files were added in the Datafari repo.

You only need to have Docker 18.09+ running

And launch the build with this command : 

DOCKER_BUILDKIT=1 docker build -f DockerfileDev -t datafaridev . 


As you can see in the documentation, you can develop and debug your Datafari code in a Debian or Ubuntu environment. But in this page we detail how to develop for other environments like MacOS X thanks to Docker for hosting Datafari. So you develop locally on your PC/Mac and you deploy on Docker to see the changes.

The different steps are :

  • 1.Clone the Datafari code

  • 2. Set up your Eclipse environment

  • 3. Set up your Docker environment :

  • 4. Do some changes and deploy !

Pre-requisites

  • Have a JDK installed on your PC/Mac (Java 8)

  • Have an IDE installed on your PC/Mac (in the guide we use Eclipse) and be able to launch it as root

  • Have Git installed on your PC/Mac

  • Have Maven and Ant installed on your PC/Mac

  • Have Docker installed on your PC/Mac


The first steps are pretty much the same than for a setup on a Linux environment. You can refer to the page for further explanations on the first steps : Setup development environment with Eclipse (Linux) for Datafari 4.x.


1. Clone the Datafari code

Open a terminal and navigate to the folder where you want to have Datafari source code to be checked out (usually your workspace folder).

Perform a

git clone https://github.com/francelabs/datafari.git

to checkout the code. The root directory name is datafari.


2. Set up your Eclipse environment

Build Datafari for the development environment

Navigate to the folder datafari. We now call it DATAFARI_SRC.

Run in DATAFARI_SRC :


mvn install 


Run in DATAFARI_SRC/debian7 :

ant all 

Open the project in Eclipse

In Eclipse,go to File -> Import... , type maven and « Existing Maven project ».

Select the DATAFARI_SRC folder as root directory and click Finish. 

3. Set up your Docker environment


  • Create a Dockerfile

Create a folder on your local PC/Mac and create a Dockerfile with this content :


FROM openjdk:8-jdk-stretch
MAINTAINER Olivier Tavard FRANCE LABS <olivier.tavard@francelabs.com>

# temporary allow unauthenticatedparameter due to debian repo issue
RUN apt-get update && apt-get install --allow-unauthenticated -y \
wget \
curl \
jq \
debconf \
python-minimal \
sudo \
vim \
nano \
netcat \
libc6-dev \
unzip \
lsof \
procps \
dialog \
&& rm -rf /var/lib/apt/lists/*
EXPOSE 8080 9080 8983 5601 9200
RUN useradd -m demo && echo "demo:demo" | chpasswd && adduser demo sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
WORKDIR /var/datafari
COPY . .



  • Copy the deb generated in one of the previous steps into the folder where you created your Dockerfile

cp your_datafari_code_folder/debian7/installer/dist/datafari.deb /docker-datafari-folder/
  • Build the Docker image :

cd your_datafari_code_folder

docker build -t datafaridev .

The build should be successful like that :

  • Run the Docker container

Note that we use the bind mount of Docker to be able to take into account the files modified in Eclipse directly in the Docker container.

The syntax of the bind mount is : /your_datafari_code/folder/datafari-webpp/target/Datafari:/var/datafari/webapp

So the command is :

docker run -p 9999:8080 -p 8999:8983 -ti -v /your_datafari_code/folder/datafari-webpp/target/Datafari:/var/datafari/webapp devdatafarice bash

Explanations :

-p 9999:8080 -p 8999:8983 -p 5601:5601 : it is the mapping between the ports that you want to expose on the container and the ports that you want to open for this on your PC/Mac to access. The first number is the local port, the second number is the port on the container.
devdatafarice : the name of the DOcker image that we build on the previous step

-ti and bash : the parameter -ti and the command bash indicate that we want to launch the container into interactive mode and launch the bash command

If the docker run command is successful, your prompt changed and you are in the /var/datafari folder.


You can now install Datafari on the container :

dpkg -i datafari.deb

Keep the default value for IP (127.0.0.1), choose the passwords that you want.

After that, launch Datafari :

cd /opt/datafari/bin

su demo

bash

bash start-datafari.sh


You can now access to the Datafari UI !

Open your browser and access to Datafari in your localhost, the port is the port that you entered in the previous stpe ie 9999.

http://localhost:9999/Datafari

You should see the Datafari front page :


4. Do some changes and deploy


Now that we have a fully functional instance of Datafari in running state, how to deploy changes that we do on Datafari code on Eclipse on the Datafari Docker container ?

Let's do this !

  • Modification on the Java code

In Eclipse, open datafari-webapp project.

Let's say that we want to change the class Synonyms in com.francelabs.datafari.servlets.admin :

We replace the l.117 : 

jsonResponse.put("synonymsList", synonymsList);

by :

jsonResponse.put("HelloDockerDatafari", synonymsList);


Save the file

We launch a maven build on the datafari-webapp project :

On your local PC/Mac :

Go to the folder that contains your Datafari code Then launch :

mvn install -pl datafari-webapp -am


On the Docker container :
Stop Datafari :

cd /opt/datafari/bin

bash stop-datafari.sh


Copy the content of the /var/datafari folder into Datafari installation folder :

cp -r /var/datafari/webapp/* /opt/datafari/tomcat/webapps/Datafari/


Start Datafari :

cd /opt/datafari/bin

bash start-datafari.sh


You should see the change that you made into the developer tools when you access to the Synonyms admin UI :


  • Modification on the UI

If you want to do some basic change on the UI, the previous process is not useful. We can simplify the process.

Let's say that we want to do a change in the Javascript of the synonyms. For this we edit the file synonyms.js located in /your_datafari_code/datafari-webapp/src/main/webapp/ajax/js/synonyms.js

We add an alert at the load of the page :

add the line : 

alert("Hello Docker Datafari !");


after :

$(document).ready(function() {


Save the file.

On your local PC/Mac :

Go to the folder that contains your Datafari code Then launch :

mvn install -pl datafari-webapp -am -DskipTests


On the Docker container :

Copy directly the js folder of the /var/datafari folder into Datafari installation folder :

cp -r /var/datafari/webapp/ajax/* /opt/datafari/tomcat/webapps/Datafari/ajax/

You should see the change that you made into the developer tools when you access to the Synonyms admin UI :

  • Remote debug on Tomcat

TBD


  • No labels