{"id":41740447,"url":"https://github.com/hayk96/trafficlight-docker-challenge","last_synced_at":"2026-01-25T00:12:42.493Z","repository":{"id":41141936,"uuid":"422634923","full_name":"hayk96/trafficlight-docker-challenge","owner":"hayk96","description":":whale: A set of practice tasks for people who are new to Docker","archived":false,"fork":false,"pushed_at":"2023-04-22T09:22:19.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-05-27T15:25:30.551Z","etag":null,"topics":["docker","docker-compose","learn-docker","learning","nginx"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hayk96.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":"CODEOWNERS","security":null,"support":null}},"created_at":"2021-10-29T15:59:41.000Z","updated_at":"2023-04-22T09:24:22.000Z","dependencies_parsed_at":"2023-01-21T10:04:27.621Z","dependency_job_id":null,"html_url":"https://github.com/hayk96/trafficlight-docker-challenge","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/hayk96/trafficlight-docker-challenge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hayk96%2Ftrafficlight-docker-challenge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hayk96%2Ftrafficlight-docker-challenge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hayk96%2Ftrafficlight-docker-challenge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hayk96%2Ftrafficlight-docker-challenge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hayk96","download_url":"https://codeload.github.com/hayk96/trafficlight-docker-challenge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hayk96%2Ftrafficlight-docker-challenge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28739409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"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":["docker","docker-compose","learn-docker","learning","nginx"],"created_at":"2026-01-25T00:12:41.882Z","updated_at":"2026-01-25T00:12:42.487Z","avatar_url":"https://github.com/hayk96.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n[![Medium][medium-shield]][medium-url]\n[![Stackoverflow][stackoverflow-shield]][stackoverflow-url]\n\n# :vertical_traffic_light: Traffic Light Docker Challenge\n\n\u003e A set of practice tasks for people who new to Docker\n\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#project-structure\"\u003eProject Structure\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#requirements\"\u003eRequirements\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#what-you-will-learn\"\u003eWhat you will learn\u003c/a\u003e\u003c/li\u003e    \n    \u003cli\u003e\u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#author-and-maintainer\"\u003eAuthor and maintainer\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n## About The Project\nIn this project are included a set of tasks designed for beginner Programmers, Systems Administrators, DevOps Engineers, etc. who want to learn or get more familiar with Docker.\n\n## Project structure\nThis project consists of folders appropriately by the color names of a traffic light: red, yellow, and green. Each of them contains the source code of the appropriate web application.\n```\n.\n├── _config.yml\n├── CODEOWNERS\n├── LICENSE\n├── README.md\n├── red\n│   ├── app.js\n│   ├── Dockerfile\n│   ├── favicon.ico\n│   ├── package.json\n│   └── index.pug\n├── yellow\n│   ├── app.js\n│   ├── Dockerfile\n│   ├── favicon.ico\n│   ├── package.json\n│   └── index.pug\n└── green\n    ├── app.js\n    ├── Dockerfile\n    ├── favicon.ico\n    ├── package.json\n    └── index.pug\n```   \n\n## Requirements\n- [Docker engine](https://docs.docker.com/engine/install/)\n- [Docker compose](https://docs.docker.com/compose/install/)\n\n## What you will learn\nBy completing all the instructions of this project, at the end of it, you will have knowledge of:\n- the basic commands of the Docker\n- networking of the Docker\n- container management with Docker compose\n- data management by using Docker volumes\n- experience with Nginx reverse proxy\n\n## Getting started\n#### Clone [this](https://github.com/hayk96/trafficlight-docker-challenge) repository, then do the required instructions of the tasks.\n\n### :one: Task1: Writing Dockerfiles and building Docker images\n1.1 Write a Dockerfile for all applications by following the instructions (from 1.1.1 to 1.1.8) presented below. The created sampler of Dockerfile should be the same for all applications.  \n- 1.1.1 Docker images must be based on this \u003cins\u003ebase image\u003c/ins\u003e `node:17.0-alpine3.14`  \n- 1.1.2 The \u003cins\u003eworking directory\u003c/ins\u003e inside the containers should be the `/app` directory  \n- 1.1.3 Copy the `package*.json` files to the working directory `/app` before installation of the `npm` package manager\n- 1.1.4 Install the `npm` package manager via `apk` (APK stands for Alpine Linux package keeper/manager). The required version of the npm is `npm=7.17.0-r0`. [See how to install packages in Alpine](https://wiki.alpinelinux.org/wiki/Alpine_Package_Keeper#Add_a_Package). After the \u003cins\u003eapk\u003c/ins\u003e instruction install dependency packages with the `nmp install` command\n- 1.1.5 Copy the `app.js` file to the working directory  \n- 1.1.6 Copy the `index.pug` and `favicon.ico` files to the `/app/views/` directory  \n- 1.1.7 All containers must expose the port `80`\n- 1.1.8 All containers should execute the following command: `node app.js` in run time\n\n\n1.2 Build Docker images for each web app, with following namings:\n- trafficlight/red:v1.0\n- trafficlight/yellow:v1.0\n- trafficlight/green:v1.0\n\n### :two: Task2: Running web apps behind Nginx reverse proxy\n2.1 Create a docker network with name `traffic-light`, and assign the `172.20.0.1` as a gateway address with `/16` prefix length.\n\n2.2 By using the created images, run containers with following requirements:\n- assign the appropriate names: `red-app`, `yellow-app` and `green-app` to containers\n\n- assign the network `traffic-light` to all containers\n\n2.3 Pull the image `nginx:1.21` then run a container with the following requirements:\n- assign the name `nginx-proxy` to the container\n\n- assign the network `traffic-light` to the container `nginx-proxy`\n\n- mount the path `~/nginx/conf.d/` of the host to the path `/etc/nginx/conf.d/` of the container - for managing configurations from your machine\n\n- the `nginx-proxy` container must listen to the following ports: `3000`, `4000` and `5000`. The mentioned ports should map to the web apps as follows: (3000 -\u003e red-app, 4000 -\u003e yellow-app, 5000 -\u003e green-app). ***:bulb: This point must be implemented via [nginx_proxy_pass](http://nginx.org/en/docs/http/ngx_http_proxy_module.html)***.\n\nIf you have done all points of the Task2 correctly, by opening e.g. the link http://127.0.0.1:3000 on your browser, you should see the `red-app` page. The rest web apps should work with the same logic.\n\n### :three: Task3: Running web apps with Nginx load balancing\n3.1 Run services via Docker Compose with the following requirements by using the web apps' images that you've built:\n- define the following services: `red-app`, `yellow-app`, `green-app` and `nginx-load-balancer` in docker-compose.yml file\n- all the services must share the `traffic-light` network\n\n3.2 For the `nginx-load-balancer` service mount the paths from the host to the container as follows:\n\n- `~/nginx/conf.d/ -\u003e /etc/nginx/conf.d/` - by allowing configuration management to be done from the host\n\n- `/var/log/nginx/ -\u003e /var/log/nginx/` - by making the Nginx logs accessible on the host\n\n- expose the port `80` for the `nginx-load-balancer` service\n\n3.3 Make load balancing of request for the all services. ***:bulb: This point must be implemented via [Nginx HTTP Load Balancing](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).***\n\n3.4 Restrict access of all web apps with the [Nginx HTTP Basic Authentication](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/).\n\nIf you have done all points of the Task3 correctly, by visiting with this link: http://127.0.0.1 first time you will see e.g. the `red-app`, visiting second time (or refreshing the page) you will see e.g. the `yellow-app`, and for the third time you will see the `green-app`.\n\n## License\nDistributed under the MIT License. See `LICENSE` for more information.\n\n\u003c!-- CONTACT --\u003e\n## Author and maintainer\n**Hayk Davtyan | [@hayk96](https://github.com/hayk96)**\n\n[contributors-shield]: https://img.shields.io/github/contributors/hayk96/trafficlight-docker-challenge.svg?style=for-the-badge\n[contributors-url]: https://github.com/hayk96/trafficlight-docker-challenge/contributors\n[forks-shield]: https://img.shields.io/github/forks/hayk96/trafficlight-docker-challenge.svg?style=for-the-badge\n[forks-url]: https://github.com/hayk96/trafficlight-docker-challenge/network/members\n[stars-shield]: https://img.shields.io/github/stars/hayk96/trafficlight-docker-challenge?style=for-the-badge\n[stars-url]: https://github.com/hayk96/trafficlight-docker-challenge/stargazers\n[issues-shield]: https://img.shields.io/github/issues/hayk96/trafficlight-docker-challenge.svg?style=for-the-badge\n[issues-url]: https://github.com/hayk96/trafficlight-docker-challenge/issues\n[license-shield]: https://img.shields.io/github/license/hayk96/trafficlight-docker-challenge.svg?style=for-the-badge\n[license-url]: https://github.com/hayk96/trafficlight-docker-challenge/blob/main/LICENSE\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/hayk96\n[medium-shield]: https://img.shields.io/badge/-Medium-black.svg?style=for-the-badge\u0026logo=medium\u0026colorB=555\n[medium-url]: https://hayk96.medium.com\n[stackoverflow-shield]: https://img.shields.io/badge/-Stackoverflow-black.svg?style=for-the-badge\u0026logo=stackoverflow\u0026colorB=555\n[stackoverflow-url]: https://stackoverflow.com/users/16454242/hayk-davtyan?tab=profile\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhayk96%2Ftrafficlight-docker-challenge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhayk96%2Ftrafficlight-docker-challenge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhayk96%2Ftrafficlight-docker-challenge/lists"}