{"id":16143129,"url":"https://github.com/johnbedeir/end-to-end-devops-aws-php-mysql","last_synced_at":"2025-07-13T16:33:09.757Z","repository":{"id":216409680,"uuid":"741263718","full_name":"johnbedeir/End-to-End-DevOps-AWS-PHP-MySQL","owner":"johnbedeir","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-07T09:42:34.000Z","size":1491,"stargazers_count":8,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-13T01:29:08.980Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","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/johnbedeir.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":"2024-01-10T03:08:27.000Z","updated_at":"2024-11-27T07:28:12.000Z","dependencies_parsed_at":"2024-01-28T05:27:12.817Z","dependency_job_id":"4a9e0ffe-3458-4f0f-874e-8beaf249cacc","html_url":"https://github.com/johnbedeir/End-to-End-DevOps-AWS-PHP-MySQL","commit_stats":null,"previous_names":["johnbedeir/end-to-end-devops-php-mysql","johnbedeir/end-to-end-devops-aws-php-mysql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FEnd-to-End-DevOps-AWS-PHP-MySQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FEnd-to-End-DevOps-AWS-PHP-MySQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FEnd-to-End-DevOps-AWS-PHP-MySQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbedeir%2FEnd-to-End-DevOps-AWS-PHP-MySQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnbedeir","download_url":"https://codeload.github.com/johnbedeir/End-to-End-DevOps-AWS-PHP-MySQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247536936,"owners_count":20954850,"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":[],"created_at":"2024-10-10T00:08:41.673Z","updated_at":"2025-04-06T19:24:59.047Z","avatar_url":"https://github.com/johnbedeir.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# End to End DevOps Project - PHP \u0026 MySQL\n\n\u003cimg src=imgs/cover.png\u003e\n\nThis project demonstrates an end-to-end setup for a PHP and MySQL application, leveraging Apache2 as the web server. Follow these instructions to run the application locally on your Linux machine.\n\n## Prerequisites\n\nBefore you begin, ensure you have the following installed on your Linux machine:\n\n- Apache2\n- PHP 8.2\n- MySQL\n- Composer\n\n## 1. Running the Application Locally\n\n### Step 1: Install Composer\n\nDownload and install Composer globally:\n\n```bash\ncurl -sS https://getcomposer.org/installer | php\nmv composer.phar /usr/local/bin/composer\n```\n\n### Step 2: Initialize Composer\n\nNavigate to your project directory and initialize Composer:\n\n```bash\ncd task-management-system\ncomposer init\n```\n\n### Step 3: Install Dependencies\n\nInstall the necessary PHP packages:\n\n```bash\ncomposer install\ncomposer require vlucas/phpdotenv\n```\n\n### Step 4: Install Apache\n\nInstall Apache2:\n\n```bash\nsudo apt install apache2\n```\n\n### Step 5: Install PHP with MySQL Support\n\nInstall PHP 8.2 along with the required modules:\n\n```bash\nsudo apt-get install php8.2 php8.2-mysql php8.2-cli php8.2-common\nsudo apt-get install php-mysql\nsudo a2enmod php8.2\nsudo systemctl restart apache2\n```\n\n## Running the Application\n\nAfter completing the setup, place your PHP project files in the appropriate Apache directory (commonly `/var/www/html`). Then, navigate to `localhost` or the respective IP address in your web browser to view your application.\n\n## Troubleshooting\n\nIf you encounter any issues, ensure that:\n\n- All services (Apache2, MySQL) are running.\n- PHP version compatibility is checked.\n- File permissions are set correctly in the Apache directory.\n\n## For detailed logs, check Apache's error log usually located at `/var/log/apache2/error.log`.\n\n## 2. Running the Application using Docker Compose\n\nThis project is configured to run as a set of microservices using Docker Compose, which includes services for the frontend, user management (login, registration, and dashboard), a logout service, and a MySQL database. An Nginx service is used as a reverse proxy to route requests to the appropriate microservice based on the URL path.\n\n### Prerequisites\n\n- Docker\n- Docker Compose\n\n### Build and Start the Services:\n\nUse Docker Compose to build and start the services. This might take some time initially as Docker needs to build the images for each service.\n\n```bash\ndocker-compose up --build\n```\n\nThe --build flag ensures that Docker Compose builds the images before starting the containers.\n\n### Accessing the Application:\n\nOnce all services are up and running, you can access the application by opening a web browser and navigating to:\n\n```\nhttp://localhost\n```\n\nThis will take you to the frontend service. The Nginx reverse proxy routes requests to the appropriate microservice based on the URL path:\n\n- `/` routes to the frontend service.\n- `/pages/login` routes to the user login page provided by the users-service.\n- `/pages/register` routes to the user registration page provided by the users-service.\n- `/pages/logout` routes to the logout service.\n- `/pages/dashboard` routes to the user dashboard provided by the users-service.\n\n```\nhttp {\n    server {\n        listen 80;\n\n        location / {\n            proxy_pass http://frontend:80/;\n        }\n\n        location /pages/login {\n            proxy_pass http://users-service:80;\n        }\n...................................................................\n```\n\n## 3. Deploying the Application on Minikube\n\nThis guide will walk you through the process of deploying the application on Minikube, including the frontend, logout and users-services, database, and Ingress for routing external traffic.\n\n### Prerequisites\n\n- [Minikube](https://minikube.sigs.k8s.io/docs/start/) installed on your machine.\n- [kubectl](https://kubernetes.io/docs/tasks/tools/) command-line tool installed and configured.\n\n### Steps to Deploy\n\n1. **Start Minikube:**\n\n   Begin by starting your Minikube cluster:\n\n   ```bash\n   minikube start\n   ```\n\n2. **Enable Ingress Controller:**\n\n   Enable the Ingress controller in Minikube:\n\n   ```bash\n   minikube addons enable ingress\n   ```\n\n3. **Deploy all k8s files:**\n\n   This will create the deployment and service for each of the services, and `PVC` for the database:\n\n   - frontend-service: which contains the home page of the application\n   - users-service: which contains the users login and registration page with the dashboard after login.\n   - logout-service: which contains the logout page\n   - database: deploy mysql where we have the data of the users stored.\n   - ingress: route the traffic between the deployed services\n\n   ```bash\n   kubectl apply -n NAMESPACE -f k8s/\n   ```\n\n4. **Access the Application:**\n\n   Get the Minikube IP to access your application:\n\n   ```bash\n   minikube ip\n   ```\n\n   Then, navigate to this IP address in your web browser. The Ingress controller will route the traffic to the appropriate services based on the path.\n\n5. **Delete Deployment:**\n\n   To stop the application and free resources, you can delete the deployments and services:\n\n   ```bash\n   kubectl delete -f path/to/deployment-or-service.yaml\n   ```\n\n---\n\n## 3. Deploying the Application on EKS and RDS\n\nTo deploy the application, follow these steps:\n\n### Deployment Script\n\nRun the following script:\n\n```bash\n./build.sh\n```\n\nThis script will handle the following tasks:\n\n1. Build EKS, VPC, Subnets, ECR, RDS, and Secret Manager for storing RDS credentials. It also deploys an EC2 instance for Jenkins to handle the CI process.\n2. Deploy a monitoring stack including Prometheus, Grafana, and Alertmanager.\n3. Set up Ingress.\n\n### Deployment Steps\n\nAfter running the script, follow these steps:\n\n1. Update your local kubeconfig.\n2. Ensure all old Docker images are removed.\n3. Build a new Docker image for each service.\n4. Log in to ECR (Elastic Container Registry).\n5. Push the Docker images to the repositories created on the ECR.\n6. Create namespaces for the application and ArgoCD.\n7. Fetch RDS credentials from the Secret Manager and create Kubernetes secrets with them.\n8. Apply the Kubernetes manifest files.\n9. Reveal the LoadBalancer URL of all the deployed applications.\n\n### Setting Up Jenkins\n\nTo set up Jenkins, follow these steps:\n\n1. Initialize a Jenkins EC2 instance.\n2. Connect to the EC2 instance via SSH.\n3. Create a `file.sh` script and copy the contents from `jenkins-provision.sh`. This script installs Jenkins, Docker, and AWS CLI, and reveals the Jenkins default password.\n4. Access Jenkins using the public IP of the EC2 instance (available in the Terraform output).\n5. In Jenkins, navigate to `Manage Jenkins \u003e Manage Plugins` and install the \"AWS Credential\" plugin.\n6. Go to `Manage Jenkins \u003e Manage Credentials \u003e Global credentials` and add AWS secret key and secret access key. Assign an ID to these credentials.\n7. Add your `.env` file as a secret in Jenkins:\n   - Go to `Credentials → System → Global credentials (unrestricted)`.\n   - Click `Add Credentials`.\n   - Select `Secret file` as the Kind.\n   - Upload your `.env` file.\n   - Assign an ID (e.g., `env-file-credentials`) and optionally add a description.\n   - Save the credentials.\n     \u003cimg src=\"imgs/env.png\"\u003e\n8. Configure global environment variables in Jenkins:\n\n   - Navigate to `Manage Jenkins \u003e System → Global Properties`.\n   - Tick the `Environment variables` checkbox.\n   - Add the following environment variables with their respective values:\n\n     - `FRONTEND_REPOSITORY_URI`\n     - `LOGOUT_REPOSITORY_URI`\n     - `MYSQL_JOB_REPOSITORY_URI`\n     - `USERS_REPOSITORY_URI`\n     - `TAG`\n     - `REGION`\n     - `APP_DOCKERFILE_PATH`\n     - `MYSQL_JOB_DOCKERFILE_PATH`\n\n      \u003cimg src=\"imgs/env-var.png\"\u003e\n\n### Set up CI pipelines in Jenkins:\n\n- Create a pipeline for each service\n- Go to the Jenkins Dashboard and click `Add Item`.\n- Create a new pipeline and use SCM.\n- Add the Git repository URL (use credentials if the repository is private).\n- Ensure the branch name and path to the `Jenkinsfile` are correct.\n\n  \u003cimg src=\"imgs/ci.png\"\u003e\n\n### Setting Up ArgoCD\n\nFor ArgoCD setup:\n\n1. Access the ArgoCD interface.\n   - Username: `admin`\n   - Password: Find it in the Kubernetes secrets.\n2. Navigate to `Settings` and connect your Git repository.\n3. Create an application for each service in the ArgoCD dashboard. Make sure to specify the correct path of the Kubernetes YAML file for each.\n\n   \u003cimg src=\"imgs/argo.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbedeir%2Fend-to-end-devops-aws-php-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbedeir%2Fend-to-end-devops-aws-php-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbedeir%2Fend-to-end-devops-aws-php-mysql/lists"}