- solr image(solr-app) and application artifact(IndianTownsAPI.war) in tomcat image(app) are packaged together as 2 services in docker-compose.yml
- Dockerfile has the steps to copy the generated war file and start tomcat. dockerfile tag is used in docker-compose.yml file to use Dockerfile
- application.properties has spring.data.solr.host=http://solr-app:8983/solr to refer the solr-app image name.
- This example has references to network concept in docker
- packaging type used is war and it is copied into image's /usr/local/tomcat/webapps path
- depends_on is specified as "solr-app" used so that tomcat image is built and dependent on "solr-app" image.
- Pull or download code from this repo
- Install Docker
- Once installed, start the Docker application in your system
- Once started, run the following commands
> mvn clean install
> docker-compose up --build
Thats it !!!
You can verify the success of setup by visiting http://localhost:8983/solr in your browser & selecting the IndianTowns core
http://localhost:8080/india/town/all?page=0&size=1
http://localhost:8080/india/town/paged/search?page=10&size=0&district=porbandar&state=gujarat
http://localhost:8080/india/town/paged/search?page=10&size=0&state=gujarat
http://localhost:8080/india/town/search?page=10&size=0&district=porbandar&state=gujarat
http://localhost:8080/india/town/search?page=10&size=0&state=gujarat
http://localhost:8080/india/town/search?state=assam&district=Nalbari
[
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"T.C",
"state":"Assam",
"district":"Nalbari",
"town_name":"Tihu"
}
]
http://localhost:8080/india/town/paged/search?page=10&size=0&state=gujarat
{
"content":[
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"M.B",
"state":"Assam",
"district":"Nalbari",
"town_name":"Nalbari"
},
{
"category":"T.C",
"state":"Assam",
"district":"Nalbari",
"town_name":"Tihu"
}
],
"pageable":{
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"offset":0,
"pageSize":20,
"pageNumber":0,
"unpaged":false,
"paged":true
},
"facetResultPages":[
],
"facetQueryResult":{
"content":[
],
"pageable":"INSTANCE",
"totalPages":1,
"totalElements":0,
"last":true,
"size":0,
"numberOfElements":0,
"first":true,
"number":0,
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"empty":true
},
"highlighted":[
],
"maxScore":null,
"fieldStatsResults":{
},
"suggestions":[
],
"facetFields":[
],
"facetPivotFields":[
],
"allFacets":[
null
],
"alternatives":[
],
"totalPages":1,
"totalElements":3,
"size":20,
"numberOfElements":3,
"first":true,
"number":0,
"sort":{
"sorted":false,
"unsorted":true,
"empty":true
},
"last":true,
"empty":false
}