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 34 Next »

Docker is a software containerization platform.

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

This is useful when running OpenSRP server because it requires mysql, couchdb, couchdb-lucene, activemq and openmrs services to be installed.

Before going through this setup, checkout the links below to install docker:

Steps for setting up OpenSRP docker container

  1. Checkout  opensrp-server and compile opensrp war file i.e. OpenSRP Server Build step 6.
    1. Change MySQL and CouchDB database credentials in opensrp.properties file
    2. Change MySQL credentials in quartz.properties
    3. Change ActiveMQ configuration in activemq.properties if applicable
  2. Checkout opensrp docker builds and navigate to the root folder.
  3. Create a webapps folder and copy the compiled war file to the new directory.

    mkdir webapps
    
    cp <opensrp-server>/opensrp-web/target/*.war webapps
  4. Build the container

    docker build -t onaio/opensrp .
  5. Run the container

    docker run -d --name='opensrp' -e MYSQL_ROOT_PASSWORD='mypassword' -e MYSQL_MOTECH_DATABASE='motechquartz' \
    -e MYSQL_OPENMRS_USER='openmrs' -e MYSQL_OPENMRS_PASSWORD='openmrs' -e MYSQL_OPENMRS_DATABASE='openmrs' \
    -e COUCHDB_USER='rootuser' -e COUCHDB_PASSWORD='adminpass' \
    -p 3306:3306 -p 5984:5984 -p 5985:5985 -p 8161:8161 -p 61616:61616 -p 9090:8080 onaio/opensrp

    The docker run command given starts a container named 'opensrp' with the following variables and ports

    Variables https://docs.docker.com/engine/reference/run/#/env-environment-variables

    ENVDescription
    MYSQL_ROOT_PASSWORD
    password for mysql root user
    MYSQL_MOTECH_DATABASE
    motech database name
    MYSQL_OPENMRS_USER
    openmrs database user name
    MYSQL_OPENMRS_PASSWORD
    openmrs database password
    MYSQL_OPENMRS_DATABASE
    openmrs database name
    COUCHDB_USER 
    couchdb root/system user name [Optional]
    COUCHDB_PASSWORD 
    couchdb root/system password [Optional]

    Ports https://docs.docker.com/engine/reference/run/#/expose-incoming-ports

    ServiceHost PortContainer Port
    mysql33063306
    couchdb59845984
    couchdb-lucene59855985
    activemq81618161
    activemq6161661616
    tomcat790908080

    NB: Host ports can be changed i.e. if mysql is already installed in port 3306, host port 3306 can be changed to 3307.


  6. Check the logs

    docker logs -f opensrp
    

    -f option follows log output.

    No errors/exceptions should be displayed in the logs if the container has started successfully.


  7. Copy opensrp war to the container's webapps folder

    docker cp webapps/opensrp.war opensrp:/opt/tomcat/webapps
  8. Test the services

    ServiceLinkCredentials
    OpenSRP http://localhost:9090/opensrp
    OpenMRS http://localhost:9090/openmrsadmin/Admin123
    CouchDB http://localhost:5984rootuser/adminpass
    CouchDB Lucene http://localhost:5984
    ActiveMQ http://localhost:8161
    MySQLhttp://localhost:3306root/mypassword

Some useful commands

CommandDescription

docker stop opensrp

Stops opensrp container

docker rm opensrp

Removes opensrp container
docker rmi onaio/opensrpRemoves onaio/opensrp image
docker exec -it opensrp bashGo to opensrp container
docker ps -a (-a shows all containers)List containers
docker imagesList images

Checkout Docker Compose Setup for an advanced docker setup.

Checkout Cloudant Sync Security Configuration especially step 8 for information on how to link lucene with a secure CouchDB. This can be helpful when COUCHDB_USER and COUCHDB_PASSWORD variables have been set.

References

https://docs.docker.com/

https://hub.docker.com/_/mysql/

https://hub.docker.com/_/couchdb/

https://github.com/klaemo/docker-couchdb-lucene

https://hub.docker.com/r/rmohr/activemq/

https://gist.github.com/robcowie/3833088

OpenSRP Server Build

Server for your App in 15 mins

  • No labels