Warning |
---|
TODO : reorganize the documentation |
Info |
---|
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 other 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
811)
Have an IDE installed on your PC/Mac (in the guide we use Eclipse)
and be able to launch it as rootHave 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.
...
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
launch the command :
Code Block |
---|
git clone https://github.com/francelabs/datafari.git |
...
Navigate to the folder datafari. We now call it DATAFARI_SRC.
Run in DATAFARI_SRC :
Code Block |
---|
mvn install' |
Run in
...
DATAFARI_SRC
...
Run /linux :
Code Block |
---|
ant all' in DATAFARI_SRC/debian7 |
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.
Change the permissions of the following folders :
Code Block |
---|
chmod -R 777 /opt/datafari
chmod -R 700 /opt/datafari/pgsql |
To add access rights to any user on datafari installation folder. Be careful : this should be done only for the development environment and should be avoided for a production deployment!
3. Set up your Docker environment
Build the Docker image :
cd your_datafari_code_folder
Code Block |
---|
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 :
Code Block |
---|
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 :
Code Block |
---|
jsonResponse.put("synonymsList", synonymsList); |
by :
Code Block |
---|
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 :
Code Block |
---|
mvn install -pl datafari-webapp -am |
On the Docker container :
Stop Datafari :
Code Block |
---|
cd /opt/datafari/bin
bash stop-datafari.sh |
Copy the content of the /var/datafari
folder into Datafari installation folder :
Code Block |
---|
cp -r /var/datafari/webapp/* /opt/datafari/tomcat/webapps/Datafari/ |
Start Datafari :
Code Block |
---|
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 :
Code Block |
---|
alert("Hello Docker Datafari !"); |
after :
Code Block |
---|
$(document).ready(function() {
|
...
Save the file.
On your local PC/Mac :
Go to the folder that contains your Datafari code Then launch :
Code Block |
---|
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 :
Code Block |
---|
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
...
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
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 :
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 :
Pre-requisites
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 codeOpen 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
to checkout the code. The root directory name is datafari. 2. Set up your Eclipse environmentBuild Datafari for the development environmentNavigate to the folder datafari. We now call it DATAFARI_SRC. Run in DATAFARI_SRC :
Run in DATAFARI_SRC/debian7 :
Open the project in EclipseIn 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 folder on your local PC/Mac and create a Dockerfile with this content :
|
...
cd your_datafari_code_folder
The build should be successful like that : |
...
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 :
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. -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 :
Keep the default value for IP (127.0.0.1), choose the passwords that you want. After that, launch Datafari :
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 !
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 :
by :
|
...
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 :
On the Docker container :
Copy the content of the /var/datafari folder into Datafari installation folder :
Start Datafari :
You should see the change that you made into the developer tools when you access to the Synonyms admin 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 :
after :
|
...
Save the file. On your local PC/Mac : Go to the folder that contains your Datafari code Then launch :
On the Docker container :
You should see the change that you made into the developer tools when you access to the Synonyms admin UI : |
...
TBD |