{"id":50532841,"url":"https://github.com/dsaikiran01/mean-stack-crud-app-deployment","last_synced_at":"2026-06-03T15:01:38.661Z","repository":{"id":340337098,"uuid":"1165526593","full_name":"dsaikiran01/mean-stack-crud-app-deployment","owner":"dsaikiran01","description":"DevOps project deploying a MEAN stack application with Docker and Nginx, automated CI/CD using GitHub Actions, AWS EC2 infrastructure, and zero-downtime updates via Docker Hub.","archived":false,"fork":false,"pushed_at":"2026-02-24T12:13:59.000Z","size":604,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-24T15:53:48.929Z","etag":null,"topics":["aws-ec2","docker","docker-compose","github","github-actions","mean-stack","nginx"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/dsaikiran01.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-24T09:03:44.000Z","updated_at":"2026-02-24T12:22:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dsaikiran01/mean-stack-crud-app-deployment","commit_stats":null,"previous_names":["dsaikiran01/mean-stack-crud-app-deployment"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/dsaikiran01/mean-stack-crud-app-deployment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsaikiran01%2Fmean-stack-crud-app-deployment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsaikiran01%2Fmean-stack-crud-app-deployment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsaikiran01%2Fmean-stack-crud-app-deployment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsaikiran01%2Fmean-stack-crud-app-deployment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsaikiran01","download_url":"https://codeload.github.com/dsaikiran01/mean-stack-crud-app-deployment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsaikiran01%2Fmean-stack-crud-app-deployment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33870026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"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":["aws-ec2","docker","docker-compose","github","github-actions","mean-stack","nginx"],"created_at":"2026-06-03T15:01:37.733Z","updated_at":"2026-06-03T15:01:38.654Z","avatar_url":"https://github.com/dsaikiran01.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MEAN Stack Application Deployment with Docker, Nginx, and GitHub Actions CI/CD\n\n\n## Index\n1. [Overview](#1-overview)  \n2. [Architecture](#2-architecture)  \n3. [Repository Structure](#3-repository-structure)  \n4. [Prerequisites](#4-prerequisites)  \n5. [Local Development Setup](#5-local-development-setup)  \n6. [Dockerization](#6-dockerization)  \n   - [Backend](#backend-dockerfile)  \n   - [Frontend](#frontend-dockerfile)  \n   - [Reverse Proxy](#reverse-proxy-dockerfile)  \n7. [Docker Compose Setup](#7-docker-compose-setup)  \n8. [Deployment on AWS EC2](#8-deployment-on-aws-ec2)  \n   - [EC2 Infrastructure Details](#ec2-infrastructure-details)  \n   - [Deployment Steps](#deployment-steps)  \n9. [CI/CD Pipeline](#9-cicd-pipeline)  \n   - [CI Pipeline](#ci-pipeline-image-building)  \n   - [CD Pipeline](#cd-pipeline-automatic-deployment)  \n10. [Nginx Configuration](#10-nginx-configuration)  \n11. [Screenshots Required](#11-screenshots-required)  \n12. [Conclusion](#12-conclusion)\n\n## 1. Overview\nThis project demonstrates the complete end-to-end deployment of a MEAN (MongoDB, Express.js, Angular, Node.js) application using Docker containers, Nginx reverse proxy, and a fully automated CI/CD pipeline powered by GitHub Actions.\n\nThe workflow includes:\n- Containerization of backend and frontend\n- Static file hosting using Nginx\n- Central reverse proxy using Nginx for routing\n- Automated image building and pushing to Docker Hub\n- Automatic deployment to an AWS EC2 instance\n\n\n## 2. Architecture\n\n### High-Level Deployment Architecture\n\n```mermaid\ngraph LR\n    A[User Browser] --\u003e|HTTP Port 80| B[Nginx Reverse Proxy Container]\n\n    B --\u003e|/| C[Frontend Container\u003cbr/\u003eNginx Serving Angular Build]\n    B --\u003e|/api| D[Backend Container\u003cbr/\u003eNode.js Express API]\n\n    D --\u003e|MongoDB Connection| E[MongoDB Container]\n\n    subgraph Docker Network\n        B\n        C\n        D\n        E\n    end\n```\n\n\n## 3. Repository Structure\n\n```\nproject-root/\n│\n├── backend/\n│   ├── .dockerignore\n│   ├── Dockerfile\n│   ├── server.js\n│   └── package.json\n│\n├── frontend/\n│   ├── .dockerignore\n│   ├── Dockerfile\n│   ├── nginx.conf\n│   ├── src/\n│   └── package.json\n│\n├── proxy/\n│   ├── Dockerfile\n│   └── nginx.conf\n│\n├── docker-compose.yml\n└── README.md\n```\n\n\n## 4. Prerequisites\n\n### Local Requirements\n- Docker  \n- Docker Compose  \n- Node.js (if running locally before containerization)\n\n### Cloud Requirements\n- AWS EC2 Ubuntu instance  \n- GitHub repository  \n- Docker Hub account  \n- GitHub Secrets configured for CI/CD  \n  - DOCKERHUB_USERNAME  \n  - DOCKERHUB_TOKEN  \n  - EC2_HOST  \n  - EC2_SSH_USER  \n  - EC2_SSH_KEY  \n  - AWS_ACCESS_KEY_ID  \n  - AWS_SECRET_ACCESS_KEY  \n  - AWS_REGION  \n\n\n## 5. Local Development Setup\n\nTo run the backend locally:\n```\ncd backend\nnpm install\nnode server.js\n```\n\nTo run the frontend locally:\n```\ncd frontend\nnpm install\nnpm run start\n```\n\n\n## 6. Dockerization\n\n### Backend Dockerfile\nThe backend uses Node.js and connects to MongoDB via an internal Docker network.\n\n### Frontend Dockerfile\nThe Angular application is built in production mode and served using an Nginx container.\n\n### Reverse Proxy Dockerfile\nHandles all inbound traffic and routes `/` to the frontend and `/api` to the backend.\n\nComplete Dockerfiles are inside their respective folders.\n\n\n## 7. Docker Compose Setup\n\nThe `docker-compose.yml` defines four services:\n- MongoDB  \n- Backend  \n- Frontend  \n- Reverse Proxy (exposed on port 80)\n\nDeploy locally using:\n```\ndocker compose up --build\n```\n\n\n## 8. Deployment on AWS EC2\n\n### EC2 Infrastructure Details\n\nThe following infrastructure configuration was used for deploying the MEAN stack application:\n\n**Operating System**  \n- Ubuntu Server 22.04 LTS (64-bit x86)\n\n**Instance Type**  \n- ci-7 Flex Large (or equivalent general-purpose instance)\n- Suitable resources for Docker, Nginx, Node.js, and MongoDB workloads\n\n**Key Pair**  \n- A new EC2 key pair was created during instance launch  \n- The corresponding private key (.pem) was added to GitHub Secrets as `EC2_SSH_KEY`  \n- This key is used by GitHub Actions to SSH into the server\n\n**Security Group Configuration**\n\n**Inbound Rules**\n| Port | Protocol | Purpose |\n|------|----------|----------|\n| 22   | TCP      | SSH access for deployment |\n| 80   | TCP      | HTTP access for the application |\n| 443  | TCP      | HTTPS (reserved for future use) |\n\n**Outbound Rules**\n| Destination | Protocol | Purpose |\n|------------|----------|----------|\n| 0.0.0.0/0  | All traffic | Required for pulling Docker images and package updates |\n\n**Storage and Networking**\n- Root volume: 20 GB (recommended minimum for Docker images)\n- Public IPv4 enabled\n- Elastic IP (optional but recommended)\n\n\n### Deployment Steps\n\n1. Launch an Ubuntu EC2 instance with the above specifications  \n2. Connect via SSH using your EC2 key pair  \n3. Install system updates and required dependencies  \n   ```\n   sudo apt update \u0026\u0026 sudo apt upgrade -y\n   sudo apt install docker.io -y\n   sudo apt install docker-compose -y\n   ```\n4. Clone the project repository  \n   ```\n   git clone https://github.com/dsaikiran01/mean-stack-crud-app-deployment.git\n   cd mean-stack-crud-app-deployment\n   ```\n5. Ensure your docker-compose.yml references Docker Hub images  \n6. Start the application  \n   ```\n   docker compose pull\n   docker compose up -d\n   ```\n\nThe application becomes available at:\n```\nhttp://\u003cEC2_PUBLIC_IP\u003e\n```\n\n\n## 9. CI/CD Pipeline\n\n### CI Pipeline (Image Building)\nTriggered on push to the `main` branch.\n- Builds frontend and backend Docker images\n- Tags images as `latest` and `\u003cGITHUB_SHA\u003e`\n- Pushes to Docker Hub\n\nTechnologies used:\n- GitHub Actions\n- docker/build-push-action\n- Docker Hub registry\n\nFile:\n```\n.github/workflows/ci.yml\n```\n\n### CD Pipeline (Automatic Deployment)\nTriggered when CI completes successfully.\n- Connects to EC2 using SSH\n- Pulls the latest Docker images from Docker Hub\n- Restarts containers using docker-compose\n- Prunes unused images\n\nFile:\n```\n.github/workflows/cd.yml\n```\n\n\n## 10. Nginx Configuration\n\n### Reverse Proxy (proxy/nginx.conf)\nRoutes:\n- `/` to frontend\n- `/api/` to backend\n\n### Frontend Nginx (frontend/nginx.conf)\nServes Angular SPA and handles path rewriting using:\n```\ntry_files $uri $uri/ /index.html;\n```\n\n\n## 11. Screenshots Required\n\n### 11.1 CI/CD Configuration\n\n![CI CD Configuration](./assets/01.png)\n\n### 11.2 CI Pipeline Execution\n\n![CI Pipeline Execution](./assets/02.png)\n\n### 11.3 Docker Image Build and Push\n\n![Docker Images on DockerHub](./assets/03.png)\n\n### 11.4 CD Pipeline Execution\n\n![CD Pipeline Execution](./assets/04.png)\n\n### 11.5 AWS EC2 Deployment\n\n![Application Deployment](./assets/05.png)\n\n### 11.6 Application Working UI\n\n![Frontend](./assets/06.png)\n\n![Backend API](./assets/07.png)\n\n\n## 12. Conclusion\n\nThis project demonstrates a complete end-to-end DevOps workflow, including containerization, orchestration with Docker Compose, Nginx reverse proxy routing, and a fully automated CI/CD pipeline using GitHub Actions for reliable deployment to AWS EC2. The setup follows industry-standard production practices and provides a robust, scalable deployment model for MEAN stack applications.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsaikiran01%2Fmean-stack-crud-app-deployment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsaikiran01%2Fmean-stack-crud-app-deployment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsaikiran01%2Fmean-stack-crud-app-deployment/lists"}