{"id":31692527,"url":"https://github.com/abdulrahmanalpha/ci-cd-webapp-ec2","last_synced_at":"2025-10-08T14:53:52.720Z","repository":{"id":316668022,"uuid":"1064362779","full_name":"AbdulrahmanAlpha/ci-cd-webapp-ec2","owner":"AbdulrahmanAlpha","description":"CI/CD pipeline for web application using GitHub Actions, Docker, and AWS EC2.","archived":false,"fork":false,"pushed_at":"2025-09-26T01:11:36.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-26T02:34:49.533Z","etag":null,"topics":["automation","aws","ci-cd","cloud","devops","docker","ec2","github-actions","pipeline"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/AbdulrahmanAlpha.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-25T23:36:39.000Z","updated_at":"2025-09-26T01:11:39.000Z","dependencies_parsed_at":"2025-09-26T02:34:55.142Z","dependency_job_id":"7eac32ea-d0e5-4a73-98e2-515e0e2e0baa","html_url":"https://github.com/AbdulrahmanAlpha/ci-cd-webapp-ec2","commit_stats":null,"previous_names":["abdulrahmanalpha/ci-cd-webapp-ec2"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/AbdulrahmanAlpha/ci-cd-webapp-ec2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbdulrahmanAlpha%2Fci-cd-webapp-ec2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbdulrahmanAlpha%2Fci-cd-webapp-ec2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbdulrahmanAlpha%2Fci-cd-webapp-ec2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbdulrahmanAlpha%2Fci-cd-webapp-ec2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbdulrahmanAlpha","download_url":"https://codeload.github.com/AbdulrahmanAlpha/ci-cd-webapp-ec2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbdulrahmanAlpha%2Fci-cd-webapp-ec2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278963833,"owners_count":26076542,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["automation","aws","ci-cd","cloud","devops","docker","ec2","github-actions","pipeline"],"created_at":"2025-10-08T14:53:38.402Z","updated_at":"2025-10-08T14:53:52.714Z","avatar_url":"https://github.com/AbdulrahmanAlpha.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 CI/CD Pipeline for Web Application\n\n**Stack:** GitHub Actions · Docker · AWS EC2\n\n---\n\n![Terraform](https://img.shields.io/badge/IaC-Terraform-blueviolet?logo=terraform)\n![AWS](https://img.shields.io/badge/Cloud-AWS-orange?logo=amazonaws)\n![CI/CD](https://img.shields.io/badge/CI%2FCD-Jenkins-blue?logo=jenkins)\n![Docker](https://img.shields.io/badge/Containers-Docker-blue?logo=docker)\n\n---\n\n## 📌 Project Overview\n\nThis project demonstrates how to build a **lightweight CI/CD pipeline** for deploying a web application on **AWS EC2** using **GitHub Actions** and **Docker**.\n\nThe goal was to **automate build, test, and deployment** workflows, ensuring faster delivery cycles and reproducible builds.\n\n### 🎯 Outcomes\n\n* Reduced deployment cycle time from **6 hours → 30 minutes**.\n* Increased **developer velocity** with automated linting \u0026 testing.\n* Standardized builds with **Docker images**.\n* Automated deployment to **AWS EC2** via GitHub Actions.\n\n---\n\n## 🏗️ Architecture\n\n![Architecture Diagram](docs/Architecture%20Diagram.png) \u003c!-- add polished diagram later --\u003e\n\n**Key components:**\n\n1. **GitHub Actions CI/CD:**\n\n   * Workflow triggers on `git push`.\n   * Stages: Lint → Test → Build → Push → Deploy.\n   * Uses GitHub Secrets for storing AWS credentials \u0026 SSH keys.\n\n2. **Docker:**\n\n   * Containerizes the application for reproducible builds.\n   * Images stored in AWS ECR (or Docker Hub).\n\n3. **AWS EC2:**\n\n   * Acts as the deployment target.\n   * Runs Docker containers via a **deployment script** (`remote-deploy.sh`).\n   * Pulls new image, runs container, performs health check, and swaps/rolls back.\n\n---\n\n## 📂 Repository Structure\n\n```\ncicd-pipeline-ec2/\n├── .github/workflows/    # GitHub Actions workflows (CI/CD)\n├── docker/               # Dockerfiles for containerization\n├── scripts/              # Deployment helper scripts (e.g., remote-deploy.sh)\n├── app/                  # Application source code\n├── docs/                 # Architecture docs, diagrams\n└── README.md             # Project documentation\n```\n\n---\n\n## ⚙️ Step-by-Step Implementation\n\n### 1️⃣ Setup GitHub Actions CI/CD\n\n* Created `.github/workflows/cicd.yml` with stages:\n\n  1. Lint (ESLint).\n  2. Run unit tests (Jest).\n  3. Build Docker image.\n  4. Push image to AWS ECR (or Docker Hub).\n  5. Deploy to AWS EC2 over SSH.\n\n👉 Triggered automatically on `push` to `main`.\n\n---\n\n### 2️⃣ Containerize Application with Docker\n\n* Wrote **Dockerfile** to package app (Node.js/Express).\n* Local test:\n\n```bash\ndocker build -t webapp:local docker/\ndocker run -p 3000:3000 webapp:local\n```\n\n---\n\n### 3️⃣ Provision AWS EC2\n\n* Launched an EC2 instance with:\n\n  * Docker installed.\n  * Security Group allowing SSH (22) \u0026 App traffic (3000).\n* Configured SSH keys and stored in GitHub Secrets.\n\n---\n\n### 4️⃣ Deploy to EC2\n\n* Added `scripts/remote-deploy.sh`:\n\n  * Connects via SSH.\n  * Pulls latest Docker image.\n  * Stops old container \u0026 starts new one.\n  * Performs health check.\n  * Rolls back if failure detected.\n\n👉 Run automatically from GitHub Actions after build \u0026 push.\n\n---\n\n### 5️⃣ Access the Application\n\n* Find EC2 public IP:\n\n```bash\naws ec2 describe-instances \\\n  --query \"Reservations[].Instances[].PublicIpAddress\" \\\n  --output text\n```\n\n* Open `http://\u003cEC2_PUBLIC_IP\u003e:3000` in browser.\n\n---\n\n### 6️⃣ Cleanup\n\n* Stop Docker containers on EC2:\n\n```bash\ndocker ps -q | xargs docker stop\n```\n\n* Terminate EC2 instance to avoid charges.\n\n---\n\n## 🔒 Security Notes\n\n* **AWS credentials** stored securely in **GitHub Secrets**.\n* **SSH key** used for deployment (never stored in repo).\n* Docker images tagged with commit SHA for traceability.\n* EC2 Security Group restricted to trusted IP ranges.\n\n---\n\n## 📈 Next Improvements\n\n* Add **Blue-Green Deployments** for zero-downtime releases.\n* Use **Terraform** for EC2 provisioning.\n* Replace manual SSH deploy with **AWS CodeDeploy** or **Ansible**.\n* Add monitoring/alerts with **CloudWatch + Grafana**.\n\n---\n\n## ✅ Skills Demonstrated\n\n* CI/CD with **GitHub Actions**.\n* **Dockerization** for reproducible builds.\n* Automated **EC2 deployments**.\n* Secure use of **GitHub Secrets**.\n* Real-world **DevOps automation workflow**.\n\n---\n\n## 🧑‍💻 Author\n\n**Abdulrahman A. Muhamad**\nDevOps | Cloud | SRE Enthusiast\n\n🔗 [LinkedIn](https://www.linkedin.com/in/abdulrahmanalpha) | [GitHub](https://github.com/AbdulrahmanAlpha) | [Portfolio](https://abdulrahman-alpha.web.app)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahmanalpha%2Fci-cd-webapp-ec2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdulrahmanalpha%2Fci-cd-webapp-ec2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahmanalpha%2Fci-cd-webapp-ec2/lists"}