{"id":16407650,"url":"https://github.com/sangam14/web_services","last_synced_at":"2026-02-11T17:03:36.270Z","repository":{"id":134352092,"uuid":"155143408","full_name":"sangam14/web_services","owner":"sangam14","description":"Best Practices for Deploying Production-Level Web Services using Docker","archived":false,"fork":false,"pushed_at":"2020-06-01T22:49:16.000Z","size":2330,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T08:40:07.666Z","etag":null,"topics":["aws-ec2","docker","docker-compose","docker-network","dockerfile","health-check","nginx","ubuntu","ubuntu-image","vps","webservice"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/sangam14.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":"2018-10-29T03:01:02.000Z","updated_at":"2022-09-04T06:17:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"b2eddaca-b8a8-4dc1-b460-6613e29bfbb5","html_url":"https://github.com/sangam14/web_services","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sangam14/web_services","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangam14%2Fweb_services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangam14%2Fweb_services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangam14%2Fweb_services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangam14%2Fweb_services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sangam14","download_url":"https://codeload.github.com/sangam14/web_services/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sangam14%2Fweb_services/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29338671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T16:14:43.024Z","status":"ssl_error","status_checked_at":"2026-02-11T16:14:15.258Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["aws-ec2","docker","docker-compose","docker-network","dockerfile","health-check","nginx","ubuntu","ubuntu-image","vps","webservice"],"created_at":"2024-10-11T06:14:26.172Z","updated_at":"2026-02-11T17:03:36.252Z","avatar_url":"https://github.com/sangam14.png","language":"HTML","readme":"# Best Practices for Deploying Production-Level Web Services using Docker\n\n## Tested Infrastructure\n\n\u003ctable class=\"tg\"\u003e\n  \u003ctr\u003e\n    \u003cth class=\"tg-yw4l\"\u003e\u003cb\u003ePlatform\u003c/b\u003e\u003c/th\u003e\n    \u003cth class=\"tg-yw4l\"\u003e\u003cb\u003eNumber of Instance\u003c/b\u003e\u003c/th\u003e\n    \u003cth class=\"tg-yw4l\"\u003e\u003cb\u003eReading Time\u003c/b\u003e\u003c/th\u003e\n    \n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd class=\"tg-yw4l\"\u003e\u003cb\u003e Play with Docker(testing webservice)\u003c/b\u003e\u003c/td\u003e\n    \u003ctd class=\"tg-yw4l\"\u003e\u003cb\u003e1\u003c/b\u003e\u003c/td\u003e\n    \u003ctd class=\"tg-yw4l\"\u003e\u003cb\u003e10 min\u003c/b\u003e\u003c/td\u003e\n    \n  \u003c/tr\u003e\n  \n\u003c/table\u003e\n\n## Pre-requisite\n\n- Create an account with [DockerHub](https://hub.docker.com)\n- Open [PWD](https://labs.play-with-docker.com/) Platform on your browser (test purpose)\n- AWS + EC2 instance (using ubuntu)+ or any linux base instance \n- Click on **Add New Instance** on the left side of the screen to bring up Alpine OS instance on the right side\n\n\n\nIn this article, I'm going to show you a better way to deploy your production web services. Basically we are going to use the method of running multiple production containers using docker.\nWhen you do docker in day to day work then you can come across docker-compose. Docker is really a magical tool!\nWe are gifted with tools in this modern era and we should utilize them to deliver services seamlessly.\n\n## Traditional approach (Know the existing things)\n\n![webservice1](https://github.com/sangam14/web_services/blob/master/web-services2.png)\n\u003cbr\u003e\nIn the old approach, these pieces are installed on a VPS.\u003cbr\u003e\n1.Application Server (Node JS, Java or Python)\u003cbr\u003e\n2.Proxy Server (Apache, Nginx)\u003cbr\u003e\n3.Cache Server (Redis, Memcached)\u003cbr\u003e\n4.Database Server(MySQL, PostgreSQL and MongoDB etc)\u003cbr\u003e\n\nThe old approach is not preffered because of automation is taking place, everyone using CI/CD deployemnet. We can also capture a snapshot of given environment to reduce the risk of deploying services into wrong set of conditions.\n\nAccording to microservices, the tightly coupled logic and deploy them separately. It means in above diagram, every application server is more independent and talk via HTTP or RPC. But it doesn't mean you need to choose X number of VPS instance to run services.\n\nContainers provide a nice way to simulate and isolate features within same machine or server. It's era of containerization. \nIf you wrote a service and planning to deploy it on AWS EC2 or any cloud VPS, don’t deploy your stuff as a single big chunk. Instead, run that distributed code in containers. We are going to see how to containerize our deployment using Docker and Docker Compose.\n\nLets see some practical examples.\n\n## Step 1- Install on Ubuntu AMI instance + Docker\n   1.We need an AWS account (http://aws.amazon.com/).\u003cbr\u003e\n   2.Choose EC2 from Amazon Web Services Console.\u003cbr\u003e\n   3.On the Choose an Amazon Machine Image (AMI) menu on the AWS Console. Click the Select button for a 64Bit Ubuntu image. (i.e. Ubuntu Server 14.04 LTS)\u003cbr\u003e\n   ![aws_instance](https://github.com/sangam14/web_services/blob/master/output-1.png)\n   4.For testing we can use the default (possibly free) t2.micro instance (more info on pricing).\u003cbr\u003e\n   ![aws_instance_typle](https://github.com/sangam14/web_services/blob/master/output-2.png)\n   5.Click the Next: Configure Instance Details button at the bottom right.\u003cbr\u003e\n   6.On the Configure Instance Details step, expand the Advanced Details section.\u003cbr\u003e\n   7.Under User data, select As text.\u003cbr\u003e\n   8.Enter #include https://get.docker.com into the instance User Data. CloudInit is part of the Ubuntu image we chose; it will bootstrap Docker by running the shell script located at this URL.\u003cbr\u003e\n  ![aws_instance_config](https://github.com/sangam14/web_services/blob/master/output-3.png)\n   9.We may need to set up our Security Group to allow SSH. By default all incoming ports to our new instance will be blocked by the AWS Security Group, so we might just get timeouts when we try to connect.\u003cbr\u003e\n   ![aws_instance_security_group](https://github.com/sangam14/web_services/blob/master/output-4.png)\n   10.Creating a new key pair:\u003cbr\u003e\n   ![aws_instance_key_pair](https://github.com/sangam14/web_services/blob/master/output-5.png)\n   11.After a few more standard choices where defaults are probably ok, our AWS Ubuntu instance with Docker should be running!\u003cbr\u003e\n   12.Installing with get.docker.com (as above) will create a service named lxc-docker. It will also set up a docker group and we may want to add the ubuntu user to it so that we don't have to use sudo for every Docker command.\u003cbr\u003e\n\n## Step 2 - Run webservice in production \n   1.connect to ubuntu intance using SSH\u003cbr\u003e\n ![SSH_instance](https://github.com/sangam14/web_services/blob/master/output-6.png)\n   2. clone the repository \n   ```\ngit clone https://github.com/sangam14/web_services.git\n```\n![clone](https://github.com/sangam14/web_services/blob/master/output-8.png)\n\n  3. check the docker compose is intalled or not \u003cbr\u003e\n  ![](https://github.com/sangam14/web_services/blob/master/output-9.png)\n  \n  4.Change directory to webservices as shown below \u0026 \nBringing up app using Docker Compose\u003cbr\u003e\n![](https://github.com/sangam14/web_services/blob/master/output-10.png)\n\n 5. provide Public IP of the instance \u003cbr\u003e\n ![](https://github.com/sangam14/web_services/blob/master/output%2011.png)\n 6. final output \u003cbr\u003e  \n![final_output](https://github.com/sangam14/web_services/blob/master/output%20-%207.png)\n\n\n\n## Anatomy of webservice \n\n![](https://github.com/sangam14/web_services/blob/master/web-service3.png)\nSteps to follow:\n\n\nClone the Repository:\n\n```\ngit clone https://github.com/sangam14/web_services.git\n```\n\nChange directory to webservices as shown below:\n\n\n```\ncd webservices \n```\n\nBringing up app using Docker Compose:\n \n```\ndocker-compose up \n```\n\nfor [PWD](https://labs.play-with-docker.com/) click on port you will get health check page \n\n![](https://github.com/sangam14/web_services/blob/master/web-service-4.png)\n\n\nhealth check by curl \n\n```\n$ curl http://localhost/api/v1/healthcheck\n\"2018-11-01T03:26:07.605Z/\"\n```\n## Important thing\n\nIf you see, we are creating a simple express service with a health check endpoint.\n```\nhttps://github.com/sangam14/web_services/blob/master/app/server.js\n\n```\n\ncheck the nginx configuration file.\n```\nhttps://github.com/sangam14/web_services/blob/master/nginx/default.conf\n```\n\n```\nupstream service { \n    server app:8080;\n}\n```\nnginx and app both are bridged using mynetwork, one can access another by the service name. So DNS is already taken care by docker. If this privilege is not available, we need to hard code IP in Nginx configuration file or assign a static IP from the subnet in the docker-compose.yam file. This is a wonderful thing about docker networking.\n\n```\nversion: \"2\"\nservices:\n    nginx:\n        build: ./nginx\n        ports:\n          - \"80:80\"\n        networks:\n          - mynetwork\n    app:\n        build: ./app\n        networks:\n          - mynetwork\n        expose: \n          - 8080\nnetworks:\n    mynetwork: \n        driver: bridge\n```\n\n![webservice1](https://github.com/sangam14/web_services/blob/master/web-services1.png)\nBy default, all the containers we create will fall under the same Internal IP range(Subnet). Docker networking allows us to create custom networks with additional properties like automatic DNS resolution etc.\n\nIn the above YAML file, we are creating a network called mynetwork. The services(containers) app and nginx will lie in the same subnet and can communicate to each other without the need of exposing the web service container to the outside world. In this way, we can make a single entry point to our web service that is through the Nginx service. If anyone tries to access app service directly they cannot do it because it is hidden. This actually secures our application.\n\n## Contributor - \n\nSangam biradar - smbiradar14@gmail.com -www.codexplus.in \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangam14%2Fweb_services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsangam14%2Fweb_services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsangam14%2Fweb_services/lists"}