{"id":25019566,"url":"https://github.com/iambotcoder/my-first-docker-application","last_synced_at":"2025-07-31T19:32:36.235Z","repository":{"id":273999455,"uuid":"921578079","full_name":"iambotcoder/My-First-Docker-Application","owner":"iambotcoder","description":"This project is a simple demonstration of creating and running a Dockerized Node.js application","archived":false,"fork":false,"pushed_at":"2025-01-24T08:55:21.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T11:51:44.503Z","etag":null,"topics":["aws","docker","docker-compose","nodejs"],"latest_commit_sha":null,"homepage":"","language":null,"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/iambotcoder.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":"2025-01-24T08:00:48.000Z","updated_at":"2025-01-26T17:46:17.000Z","dependencies_parsed_at":"2025-01-24T09:22:26.760Z","dependency_job_id":"e2485f37-004f-482c-9348-d73e6da7382d","html_url":"https://github.com/iambotcoder/My-First-Docker-Application","commit_stats":null,"previous_names":["iambotcoder/my-first-docker-application"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2FMy-First-Docker-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2FMy-First-Docker-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2FMy-First-Docker-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2FMy-First-Docker-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iambotcoder","download_url":"https://codeload.github.com/iambotcoder/My-First-Docker-Application/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301997,"owners_count":20755514,"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":["aws","docker","docker-compose","nodejs"],"created_at":"2025-02-05T11:51:02.333Z","updated_at":"2025-03-30T10:11:33.730Z","avatar_url":"https://github.com/iambotcoder.png","language":null,"readme":"# 🚀 My First Docker Application\n---\n\n## 📖 Overview\n\nThis project is a simple demonstration of creating and running a Dockerized Node.js application. The steps include creating a Dockerfile and docker-compose.yml, building a Docker image, and running the application using Docker Compose. This application responds with a JSON message \"Docker is easy 🐳\" when accessed via HTTP.\n\n---\n\n## 📑 Table of Contents\n- [Prerequisites](#prerequisites) 🔑\n- [Architecture](#Architecture)\n- [Architecture ](#setup-and-installation) 🗺️\n- [Docker Setup](#docker-setup) 🐳\n- [Docker Compose Setup](#docker-compose-setup) 🌐\n- [Accessing the Application](#accessing-the-application) 🌐\n- [Cleaning Up Resources](#cleaning-up-resources) 🧹\n- [Conclusion](#conclusion) ✅\n\n---\n\n## 🔑 Prerequisites\nBefore you start, ensure you have the following:\n- An AWS account 🌍\n- **Node.js** and **npm**\n- **Docker** and **Docker Compose** installed for building and pushing Docker images\n- Basic understanding of JavaScript and Docker 🧑‍💻\n\n---\n\n## 🗺️ Architecture\n\nThe application consists of two main components:\n\n- **Node.js Application:** A simple Express server serving an API.\n- **MySQL Database:** A containerized MySQL instance managed using Docker Compose.\n\n\n### Workflow:\n\n- The Node.js application runs inside a Docker container.\n- The application connects to a MySQL database running in another container.\n- Both containers are managed using Docker Compose.\n    \n## 🛠️ Setup \u0026 Installation\n\n### 1⃣ Setup Node Project\n\n1. Initialize a Node.js project:\n   ```bash\n   npm init -y\n   ```\n2. Install dependencies and start the project:\n   ```bash\n   npm install\n   npm start\n   ```\n3. Create an `index.js` file with the following content:\n   ```javascript\n   const app = require('express')();\n\n   app.get('/', (req, res) =\u003e\n       res.json({ message: 'Docker is easy 🐳' })\n   );\n\n   const port = process.env.PORT || 5000;\n\n   app.listen(port, () =\u003e console.log(`app listening on http://localhost:${port}`));\n   ```\n    \n## 🐳 Docker Setup\n\n### 2⃣ Create a Dockerfile\n\nCreate a file named `Dockerfile` in your project directory:\n\n```dockerfile\nFROM node:12\n\nWORKDIR /app\n\nCOPY package*.json ./\n\nRUN npm install\n\nCOPY . .\n\nENV PORT=5000\n\nEXPOSE 5000\n\nCMD [ \"npm\", \"start\" ]\n```\n\n### 3⃣ Build and Run the Docker Image\n\n1. Build the Docker image:\n   ```bash\n   docker build -t iambot/myfirstnodeapp:1.0 .\n   ```\n2. List Docker images:\n   ```bash\n   docker image ls\n   ```\n3. Run the Docker container:\n   ```bash\n   docker run -p 5000:8080 \u003cimageid\u003e\n   ```\n4. Check running containers:\n   ```bash\n   docker ps -a\n   ```\n\nThe application will now be accessible at [http://localhost:5000](http://localhost:5000).\n    \n### 🌐 Docker Compose Setup\n\n### 4⃣ Create a `docker-compose.yml`\n\nCreate a file named `docker-compose.yml` with the following content:\n\n```yaml\nversion: '3'\nservices:\n  web:\n    build: .\n    ports:\n      - \"3000:5000\"\n  db:\n    image: \"mysql\"\n    environment:\n      MYSQL_ROOT_PASSWORD: password\n    volumes:\n      - db-data:/foo\n\nvolumes:\n  db-data:\n```\n\n### 5⃣ Run the Application with Docker Compose\n\n1. Start the services:\n   ```bash\n   docker compose up\n   ```\n2. Stop and remove the services:\n   ```bash\n   docker compose down\n   ```\n    \n### 🛡️ Accessing the Application\n\n- Access the Node.js application at: [http://localhost:3000](http://localhost:3000).\n- The application responds with:\n  ```json\n  { \"message\": \"Docker is easy 🐳\" }\n  ```\n    \n### 🚹 Cleaning Up Resources\n\nTo clean up all resources:\n\n1. Stop and remove containers:\n   ```bash\n   docker compose down\n   ```\n2. Remove unused Docker images:\n   ```bash\n   docker image prune\n   ```\n---\n\n## ✅ Conclusion\n\nThis project demonstrates how to containerize a simple Node.js application and manage it using Docker and Docker Compose. The setup ensures an isolated and portable development environment for your application.\n\n---\n\n## 👨‍🏫 Instructor\n\nThis project was guided by ***Navin reddy*** and ***Telusko***, who provided valuable mentorship throughout the process.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambotcoder%2Fmy-first-docker-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiambotcoder%2Fmy-first-docker-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambotcoder%2Fmy-first-docker-application/lists"}