How to build Insights Docker Image (Linux)

Step - by - step guide to how to Install Insights on Linux using Docker

Prerequisite:


Install Docker:

On RHEL/Centos7:

  • yum update
  • yum install yum-utils

  • yum-config-manager --enable rhui-REGION-rhel-server-extras 
  • yum install docker
  • systemctl start docker
  • systemctl status docker
  • systemctl enable docker (start docker at system boot)

On Ubuntu:

  • apt-get update
  • apt-get upgrade
  • apt-get install docker.io
  • systemctl start docker
  • systemctl enable docker

Build Docker Image:


 UIEngineAgentDaemon

Build Image:

  1. git clone -b dockerImage https://github.com/CognizantOneDevOps/Insights.git
  2. cd Insights/dockerImageFiles/UIEngineAgentDaemonImage
  • Dockerfile
  • config.env
  • insights_wrapper.sh

      3. Convert files format to UNIX format : dos2unix *

      4. Update config.env with the below specified values.

config.env

VariablesDetails
hostIPhost machine IP where you are running docker container which will start rabbitmq,grafana and InsightsUI in this given hostIP
neo4jIPIP of Neo4j
postgresIPIP of PostgreSQL 
elassticIPIP of ElasticSearch


     5. Execute the docker build command where Dockerfile located.
       Syntax: docker build  -t   reponame:tag .
       Command: docker build -t infra.cogdevops.com:8090/onedevopsinsights:<version> .

     6. To push the built image to repo.

         docker login -u <username> -p <password> infra.cogdevops.com:8090

         docker push infra.cogdevops.com:8090/onedevopsinsights:<version>
  
List docker images: docker images

To run UIEngineAgentDaemon docker container: Insights Docker Installation

Run docker containers EngineJar/Deploy war (Obsolete):


 Engine Jar

Create Images:
Create a directory and copy files from  

  • dockerfile
  • insightsJar.sh
  • config.env

Execute the following command:

     dos2unix *

This command will convert downloaded files to UNIX format

Overview of property to be set in config.env file:
 

VariablesDetails
postgresIPIP of PostgreSQL 
neo4jIPIP of Neo4j
mqIPIP of Rabbit MQ
insightsConfigURL of InSightsConfig.zip
jdkURLURL of Java JDK
jarURLURL for updated PlatformEngine.jar

  Update config.env variables and run the below command from the path of copied files.

       docker build  -t   tag_name .

       Example : docker build  -t   insights/engine  .
  
The above command create an image with unique id which will be used to create the containers.
Check the list of images created by, 

       docker images

Create containers -
Run the image built to create containers 

        docker run -dit  --env-file  config.env  imageID  

        Let ' e10aca6729db ' be  the imageID created.

        Example :   docker run -dit  --env-file  config.env   e10aca6729db

This command will create a container and return a code,  details of  the container can be viewed by running the command ' docker ps '

 -dit runs the container in detached mode. For interactive mode use  -it.

  Ensure that  docker run   command is executed from the path where config.env is present.

To list the containers  -
        docker ps        [ For active containers ]

        docker ps -a    [ For all containers ] 

Check logs of container  -
        docker logs containerID

        Let '614bcc4546de'  be the containerID created,

        Example : docker logs  614bcc4546de


Connect to the container  -
      User can get into the newly created container where jar is running by , 

        docker exec  -it  containerID  bash    
      
        Example : docker exec  -it  614bcc4546de  bash    

 Deploy war

Create Images - 
Make a directory and copy files from   

  • dockerfile
  • insightsUI.sh
  • config.env

Execute the following command:

     dos2unix *

This command will convert downloded files to UNIX format


 Make sure that you have connection with the instance where you have other components ( Postgres, Rabbitmq, Neo4j )   



Overview of variables to be set in config.env

VariablesDetails 
elasticIPIP of Elastic Search 
postgresIPIP of PostgreSQL 
neo4jIPIP of Neo4j
mqIPIP of Rabbit MQ
ldapUrlURL of LDAP
bindDNBind DN of LDAP
bindPasswordPassword for Bind DN
searchBaseDN

Base DN for LDAP Search

jdkURLURL of Java JDK
insightsConfigURLURL of InSightsConfig.zip
grafanaURLURL of Grafana
grafanaLDAPURL of ldap.toml
grafanaDefaultsURL of defaults.ini
insightsUIURL of InSightsUI.zip
insightsWarURL of PlatformService.war
tomcatURLURL of apache tomcat


Update config.env variables and run the below command from the path of copied files.
   
        docker build  -t   tag_name .

        Example : docker build  -t   insights/ui  .
  
The above command create an image with unique id which will be used to create the containers.
Check the list of images created by, 

         docker images
   

Create containers -

Run the image built to create containers 

           docker run -dit -p 3000:3000 -p 8080:8080 --env-file  config.env   imageID  ping -t localhost

           Let ' e10aca6729db ' be  the imageID created.

           Example :   docker run -dit -p 3000:3000 -p 8080:8080 --env-file  config.env   e10aca6729db  ping -t localhost

 - dit runs the container in detached mode. For interactive mode use  - it.

 - p helps to expose specified ports. If port is already in use, try with other port of host to connect.
   Make sure that  Grafana runs on 3000 by default.


To list the containers  -

           docker ps   [ For active containers ]
           docker ps -a    [ For all containers ] 

Check logs of container  - 
           docker logs containerID

           Let '614bcc4546de'  be the containerID created,

           Example : docker logs  614bcc4546de

Connect to the container  -
   User can get into the newly created container where jar is running by , 

           docker exec  -it  containerID  bash    

           Example : docker exec  -it  614bcc4546de  bash    

Check the URLs -

Note:  insightsUI.sh file fetches publicIP of the host that you are using and run Grafana, Tomcat on relevant ports of it. 
           If any of the container orchestration utility (like kubernetes) is used in order to run this UI image, then 'ping -t localhost' is not needed at the end of 'docker run' command 

       http://hostPublicIP:3000 for grafana
       http://hostPublicIP:8080/app for Insights UI

©2021 Cognizant, all rights reserved. US Patent 10,410,152