{"id":15782995,"url":"https://github.com/keinos/imhost","last_synced_at":"2026-04-15T23:31:32.383Z","repository":{"id":229732415,"uuid":"776247296","full_name":"KEINOS/imhost","owner":"KEINOS","description":"Example of Docker Compose's \"--scale\" with Nginx's round-robin.","archived":false,"fork":false,"pushed_at":"2024-12-02T00:28:50.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-23T03:57:24.581Z","etag":null,"topics":["docker","docker-compose-template","dockerfile","host-name","round-robin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KEINOS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-23T01:42:08.000Z","updated_at":"2024-12-02T00:28:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"23784497-7f28-4d24-b282-244fff0a1158","html_url":"https://github.com/KEINOS/imhost","commit_stats":null,"previous_names":["keinos/imhost"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/KEINOS/imhost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KEINOS%2Fimhost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KEINOS%2Fimhost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KEINOS%2Fimhost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KEINOS%2Fimhost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KEINOS","download_url":"https://codeload.github.com/KEINOS/imhost/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KEINOS%2Fimhost/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31864953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: 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":["docker","docker-compose-template","dockerfile","host-name","round-robin"],"created_at":"2024-10-04T19:22:41.112Z","updated_at":"2026-04-15T23:31:32.366Z","avatar_url":"https://github.com/KEINOS.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ImHost\n\n[ImHost](./imhost) is a **web server that simply responds the \"host name\" of the server** at port 80.\n\nIts main purpose is for testing and demonstration of **load balancing** and **scaling** of Docker containers.\n\n\u003e We provide a [Dockerfile](./Dockerfile) for convenience. See the \"[Docker Compose with scale and round-robin](#docker-compose-with-scale-and-round-robin)\" section for the **full example using \"--scale\" option and Nginx as a load balancer** as well.\n\n## Usage\n\n### Docker\n\n```shellsession\n$ # Build the image\n$ docker build -t imhost https://github.com/KEINOS/imhost.git\n**snip**\n\n$ # Run the container (expose the port 80 to 8080)\n$ docker run --rm -p 8080:80 imhost\n**snip**\n\n$ # Check the hostname\n$ curl -sS http://localhost:8080/\nHello from host: f9536b7afae0\n```\n\n### Docker Compose with scale and round-robin\n\nHere is an example of `docker-compose.yml` that can:\n\n1. Scale-up `imhost` containers using `--scale` option.\n2. Load balancing using `nginx`.\n\n```shellsession\n$ # Run the containers and scale the imhost to 5 instances\ndocker compose up --scale imhost=5 --detach\n**snip**\n\n$ # Check the host names.\n$ # Note that the host names are different each time because of\n$ # the round-robin.\n$ curl -sS http://localhost:8080\nHello from host: 2c80ea38d91a\n\n$ curl -sS http://localhost:8080\nHello from host: 5fec68e38b9b\n\n$ curl -sS http://localhost:8080\nHello from host: 353184aa84c0\n```\n\n```yaml\nversion: '3'\n\nservices:\n  imhost:\n    build:\n      context: https://github.com/KEINOS/imhost.git\n    expose:\n      - \"80\"\n    restart: unless-stopped\n\n  loadbalancer:\n    image: nginx:latest\n    volumes:\n      - ./nginx.conf:/etc/nginx/nginx.conf:ro\n    ports:\n      - \"8080:80\"\n    depends_on:\n      - imhost\n    restart: unless-stopped\n```\n\n```nginx\nuser nginx;\n\nworker_processes auto;\n\nevents {\n    worker_connections 1024;\n}\n\nhttp {\n    server {\n        listen 80;\n        location / {\n            proxy_pass http://imhost:80/;\n        }\n    }\n}\n```\n\n- For the full example, see the [example](./_example) directory.\n\n## Source code\n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/KEINOS/imhost)\n[![Go Reference](https://pkg.go.dev/badge/github.com/KEINOS/imhost.svg)](https://pkg.go.dev/github.com/KEINOS/imhost)\n![GitHub License](https://img.shields.io/github/license/KEINOS/imhost)\n\n- [/imhost/main.go](./imhost/main.go)\n\n### Status\n\n[![Unit Tests](https://github.com/KEINOS/imhost/actions/workflows/unit-test.yml/badge.svg)](https://github.com/KEINOS/imhost/actions/workflows/unit-test.yml)\n[![GolangCI-Lint Test](https://github.com/KEINOS/imhost/actions/workflows/golang-ci.yml/badge.svg)](https://github.com/KEINOS/imhost/actions/workflows/golang-ci.yml)\n[![Docker Tests](https://github.com/KEINOS/imhost/actions/workflows/docker-test.yml/badge.svg)](https://github.com/KEINOS/imhost/actions/workflows/docker-test.yml)\n[![CodeQL](https://github.com/KEINOS/imhost/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/KEINOS/imhost/actions/workflows/github-code-scanning/codeql)\n\n[![codecov](https://codecov.io/gh/KEINOS/imhost/graph/badge.svg?token=7WsjthYoE6)](https://codecov.io/gh/KEINOS/imhost)\n[![Go Report Card](https://goreportcard.com/badge/github.com/KEINOS/imhost)](https://goreportcard.com/report/github.com/KEINOS/imhost)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeinos%2Fimhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeinos%2Fimhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeinos%2Fimhost/lists"}