{"id":16220320,"url":"https://github.com/mattjlewis/helloworldmicroservice","last_synced_at":"2025-04-03T03:30:35.123Z","repository":{"id":148063288,"uuid":"91801611","full_name":"mattjlewis/HelloWorldMicroservice","owner":"mattjlewis","description":"An example \"hello-world\" microservice, incoporating web, service and database tiers using NGINX to load balance the web and service tiers. Developed in Java using Spark Framework.","archived":false,"fork":false,"pushed_at":"2018-03-02T13:51:58.000Z","size":1283,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T05:51:13.998Z","etag":null,"topics":["docker","java","microservice","mysql","nginx","sparkjava","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattjlewis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-19T12:02:08.000Z","updated_at":"2023-03-30T20:43:56.000Z","dependencies_parsed_at":"2023-03-31T17:04:16.088Z","dependency_job_id":null,"html_url":"https://github.com/mattjlewis/HelloWorldMicroservice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattjlewis%2FHelloWorldMicroservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattjlewis%2FHelloWorldMicroservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattjlewis%2FHelloWorldMicroservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattjlewis%2FHelloWorldMicroservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattjlewis","download_url":"https://codeload.github.com/mattjlewis/HelloWorldMicroservice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933208,"owners_count":20857046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","java","microservice","mysql","nginx","sparkjava","spring-boot"],"created_at":"2024-10-10T11:58:23.678Z","updated_at":"2025-04-03T03:30:35.086Z","avatar_url":"https://github.com/mattjlewis.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HelloWorldMicroservice - An Example Microservice Based Application\r\n\r\n## Prepare the Host Machine\r\n\r\nAs docker-engine is only supported on Windows 10 and I am running Windows 7 I need a Linux Virtual Machine to act as my docker engine.\r\nI could create my own Linux Virtual Machine and install docker-engine on that, however, docker-machine makes this much easier.\r\nMake sure you have [VirtualBox](https://www.virtualbox.org/wiki/Downloads) installed.\r\n\r\nDocker Machine creates a lightweight Virtual Machine based on [boot2docker](http://boot2docker.io/) for hosting containers.\r\nIf on Windows or Mac install [docker-toolbox](https://www.docker.com/products/docker-toolbox) (I selected Docker Client and Docker Machine).\r\n\r\nCreate a new docker host machine and log in to it:\r\n```\r\ndocker-machine create --virtualbox-memory \"4096\"\r\ndocker-machine ssh\r\n```\r\n\r\nDownload the projects: (note may need to set proxy ```export http_proxy=www-proxy-lon.uk.oracle.com:80; export https_proxy=www-proxy-lon.uk.oracle.com:80```\r\n```\r\ngit clone https://github.com/mattjlewis/HelloWorldMicroservice\r\ncd HelloWorldMicroservice\r\n```\r\n\r\n## Docker Stuff\r\n\r\nCreate the user-defined bridge network (so we get embedded DNS):\r\n```\r\ndocker network create --driver bridge hwms_nw\r\n```\r\n\r\nBuild the machines:\r\n```\r\ndocker build -t hwms_db docker-images/hwms_db\r\ndocker build -t hwms .\r\ndocker build -t hwms_rest docker-images/hwms_rest\r\ndocker build -t hwms_web docker-images/hwms_web\r\ndocker build -t hwms_sbweb docker-images/hwms_sbweb\r\n```\r\n\r\nStart the database:\r\n```\r\ndocker run --detach --network=hwms_nw --hostname hwmsdb --name hwmsdb --publish 3306:3306 --volume /home/docker/datadir:/var/lib/mysql hwms_db\r\n```\r\n\r\nStart the REST services tier:\r\n```\r\ndocker run --detach --network=hwms_nw --hostname hwmsrest1 --name hwmsrest1 hwms_rest\r\ndocker run --detach --network=hwms_nw --hostname hwmsrest2 --name hwmsrest2 hwms_rest\r\n```\r\n\r\nStart the Spark Framework web tier:\r\n```\r\ndocker run --detach --network=hwms_nw --hostname hwmsweb1 --name hwmsweb1 hwms_web\r\ndocker run --detach --network=hwms_nw --hostname hwmsweb2 --name hwmsweb2 hwms_web\r\n```\r\n\r\nStart the Spring Boot web tier:\r\n```\r\ndocker run --detach --network=hwms_nw --hostname hwmssbweb1 --name hwmssbweb1 hwms_sbweb\r\ndocker run --detach --network=hwms_nw --hostname hwmssbweb2 --name hwmssbweb2 hwms_sbweb\r\n```\r\n\r\nStart the NGINX load balancer:\r\n```\r\ndocker run --detach --network=hwms_nw --hostname hwmslb --name hwmslb --publish 8080:80 --volume /home/docker/HelloWorldMicroservice/nginx.conf.d:/etc/nginx/conf.d:ro nginx\r\n```\r\n\r\nTest:\r\n```\r\ncurl http://localhost:8080/service/users\r\n```\r\n\r\nAccess the [Browser UI](http://localhost:8080/) via NGINX.\r\n\r\n## TODO\r\n\r\n1. Deploy to docker swarm and use ```docker service scale```\r\n1. Use docker-compose\r\n1. Use Kubernetes?\r\n1. Use ```store/oracle/serverjre:8``` rather than the unsupported ```isuper/java-oracle```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattjlewis%2Fhelloworldmicroservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattjlewis%2Fhelloworldmicroservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattjlewis%2Fhelloworldmicroservice/lists"}