Skip to content

Instantly share code, notes, and snippets.

@amjadafanah
Created January 18, 2016 00:04
Show Gist options
  • Save amjadafanah/511cbd9d3e47d2c2cdad to your computer and use it in GitHub Desktop.
Save amjadafanah/511cbd9d3e47d2c2cdad to your computer and use it in GitHub Desktop.
Docker Java application template with Nginx for load balancing, Tomcat application server, Solr for full-text search and Mongo as the underlying database. The service discovery is provided through DCHQ's plug-in framework. The service discovery framework in DCHQ provides event-driven life-cycle stages that executes custom scripts to re-configure…
Nginx:
image: nginx:latest
publish_all: true
mem_min: 50m
host: host1
plugins:
- !plugin
id: 0H1Nk
restart: true
lifecycle: on_create, post_scale_out:AppServer, post_scale_in:AppServer
arguments:
# Use container_private_ip if you're using Docker networking
- servers=server {{AppServer | container_private_ip}}:8080;
# Use container_hostname if you're using Weave networking
#- servers=server {{AppServer | container_hostname}}:8080;
AppServer:
image: tomcat:8.0.21-jre8
mem_min: 600m
host: host1
cluster_size: 1
environment:
- database_driverClassName=com.mysql.jdbc.Driver
- database_url=jdbc:mysql://{{MySQL|container_hostname}}:3306/{{MySQL|MYSQL_DATABASE}}
- database_username={{MySQL|MYSQL_USER}}
- database_password={{MySQL|MYSQL_ROOT_PASSWORD}}
- solr_host={{Solr|container_private_ip}}
- solr_port=8983
plugins:
- !plugin
id: oncXN
restart: true
arguments:
- file_url=https://github.com/dchqinc/dchq-docker-java-solr-mongo-cassandra-example/raw/master/dbconnect.war
- dir=/usr/local/tomcat/webapps/ROOT.war
- delete_dir=/usr/local/tomcat/webapps/ROOT
Solr:
image: solr:latest
mem_min: 300m
host: host1
publish_all: false
plugins:
- !plugin
id: doX8s
restart: true
arguments:
- file_url=https://github.com/dchqinc/dchq-docker-java-solr-mongo-cassandra-example/raw/master/names.zip
MySQL:
image: mysql:latest
host: host1
mem_min: 400m
environment:
- MYSQL_USER=root
- MYSQL_DATABASE=names
- MYSQL_ROOT_PASSWORD={{alphanumeric|8}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment