KnowageLabs / Knowage-Server-Docker

Docker Image packaging for Knowage Server https://www.knowage-suite.com
GNU Affero General Public License v3.0
66 stars 77 forks source link

Enhancement Request : adding jdbc sources via JNDI and volumes #20

Open jguay opened 5 years ago

jguay commented 5 years ago

At the moment beside creating a new image/Dockerfile, it is not possible to add a JDBC source at container level via environment variables or volume

similar issue : https://github.com/KnowageLabs/Knowage-Server-Docker/issues/11

Description of limitation : I try to use this doc to add a jdbc datasource in server.xml

docker-compose.yml

version: "3.6"
services:
  BI_knowage0:
    container_name: BI_knowage0
    image: knowagelabs/knowage-server-docker:6.3.3
    ports:
    - 8080:8080
    environment:
    - WAIT_MYSQL=true
    - DB_ENV_MYSQL_USER=dbuser
    - DB_ENV_MYSQL_DATABASE=knowagedb
    - DB_ENV_MYSQL_PASSWORD=p6ssword
    - DB_PORT_3306_TCP_ADDR=BI_mysql0
    - DB_PORT_3306_TCP_PORT=3306
    depends_on:
    - BI_mysql0
    volumes:
    - ./config/knowage.xml:/home/knowage/apache-tomcat-8.5.37/conf/server.xml
    - ./config/some-jdbc-package.jar:/home/knowage/apache-tomcat-8.5.37/lib/some-jdbc-package.jar
  BI_mysql0:
    image: mysql:5.6
    container_name: BI_mysql0
    environment:
    - MYSQL_USER=dbuser
    - MYSQL_PASSWORD=p6ssword
    - MYSQL_DATABASE=knowagedb
    - MYSQL_ROOT_PASSWORD=p6ssword

Then I run :

docker-compose up BI_knowage0

This results in infamous sed error:

BI_knowage0      | sed: cannot rename /home/knowage/apache-tomcat-8.5.37/conf/sedwHVP0f: Device or resource busy
BI_knowage0 exited with code 4

Possible solution : adding feature in entrypoint.sh :

Current code : https://github.com/KnowageLabs/Knowage-Server-Docker/blob/master/entrypoint.sh#L42 :

I add a random location whereby any file will be added to server.xml after line 42

sed -i "s|${old_connection}|${new_connection}|" ${KNOWAGE_DIRECTORY}/${APACHE_TOMCAT_PACKAGE}/conf/server.xml
# Adding all content of customJNDIs folder to server.xml
sed -i '/<!-- KNOWAGE -->/r'<(cat ${KNOWAGE_DIRECTORY}/${APACHE_TOMCAT_PACKAGE}/customJNDIs/*) -i -- ${KNOWAGE_DIRECTORY}/${APACHE_TOMCAT_PACKAGE}/conf/server.xml

•• Testing solution works : **

In this case to test this is working, I added the code overwriting the entrypoint.sh and then my jdbc file according to

version: "3.6"
services:
  BI_knowage0:
    container_name: BI_knowage0
    image: knowagelabs/knowage-server-docker:6.3.3
    ports:
    - 8080:8080
    environment:
    - WAIT_MYSQL=true
    - DB_ENV_MYSQL_USER=dbuser
    - DB_ENV_MYSQL_DATABASE=knowagedb
    - DB_ENV_MYSQL_PASSWORD=p6ssword
    - DB_PORT_3306_TCP_ADDR=BI_mysql0
    - DB_PORT_3306_TCP_PORT=3306
    depends_on:
    - BI_mysql0
    volumes:
    - ./config/some-new-jdbc-datasource.xml:/home/knowage/apache-tomcat-8.5.37/customJNDIs/some-new-jdbc-datasource.xml
    - ./config/some-jdbc-package.jar:/home/knowage/apache-tomcat-8.5.37/lib/some-jdbc-package.jar
    - ./config/knowage-entrypoint.sh:/home/knowage/apache-tomcat-8.5.37/bin/entrypoint.sh
  BI_mysql0:
    image: mysql:5.6
    container_name: BI_mysql0
    environment:
    - MYSQL_USER=dbuser
    - MYSQL_PASSWORD=p6ssword
    - MYSQL_DATABASE=knowagedb
    - MYSQL_ROOT_PASSWORD=p6ssword

Then I run :

docker-compose up -d BI_knowage0 && sleep 5 && docker-compose exec BI_knowage0 more /home/knowage/apache-tomcat-8.5.37/conf/server.xml

Knowage starts without issue this shows my jdbc source which I added as JNDI source... I'm just learning through knowage so I am yet to use it (I'm automating as much as possible so will try to see if I can automate the JNDI datasource creation and a report next... I just thought maybe the enhancement request makes sense to at least provide a way to add snippet into server.xml