A portfolio-ready DevOps project that automates infrastructure provisioning, code quality analysis, Docker image delivery, and application deployment for a Next.js app using Jenkins, SonarQube, Terraform, Ansible, Docker, AWS ECR, and AWS EC2.
The Git repository is the single source of truth for application code, infrastructure as code, deployment automation, and CI/CD orchestration.
Jenkins clones the GitHub repository and prepares the workspace with app, Terraform, and Ansible files.
Node packages are installed, then the Next.js application is built to validate the project before packaging.
Static code analysis runs against the app source to inspect maintainability, smells, and quality gate conditions.
A Docker image is created from the production-ready Dockerfile, packaging the Next.js app for consistent deployment.
Jenkins authenticates to ECR, creates the repository if needed, and pushes the tagged image version.
Infrastructure is provisioned on AWS, including EC2, Security Group, IAM Role, and Instance Profile.
Ansible configures the target server, logs in to ECR using the EC2 IAM role, pulls the image, and runs the container.
Container image registry for versioned NextJob Platform images.
Amazon Linux instance that runs the application container.
Attached to the EC2 instance so it can authenticate to ECR without hardcoding AWS keys.
Network rules provisioned by Terraform for secure access.
ec2-user to the Docker group
app/ contains the Next.js application and Dockerfile.
terraform/ provisions AWS resources like EC2, Security Group, IAM Role, and outputs the public IP.
ansible/ contains inventory and playbook logic to configure and deploy the app.
jenkins/ contains the pipeline script that ties all stages together.
The project starts when code is pushed to GitHub. Jenkins clones the repo, runs quality checks, builds the app, packages it as a Docker image, and pushes that image to Amazon ECR. Terraform then ensures the AWS infrastructure exists. Finally, Ansible connects to the EC2 instance over SSH and deploys the latest image from ECR.
Jenkins uses its own AWS credentials to manage infrastructure and push images. The application EC2 instance does not need embedded AWS access keys. Instead, it receives temporary credentials through an IAM Role, which is safer and closer to real production practice.
You can extend this project by adding a domain name, HTTPS with Nginx and Certbot, blue-green deployment, automated tests, CloudWatch monitoring, Slack notifications, or migration from EC2 to ECS or Kubernetes.