Welcome to the Snakes Web Application! 🎬🐍 This project demonstrates a production-grade CI/CD Pipeline on AWS, deploying a Java Web App to a raw EC2 instance without using managed services like Elastic Beanstalk.
The goal of this project is to showcase DevOps best practices by building a fully automated deployment pipeline. Problem Solved: Manual deployments are slow and error-prone. This project automates the journey from "Code Commit" to "Live Server" in minutes.
| Category | Tool | Purpose |
|---|---|---|
| Compute | Amazon EC2 (Ubuntu) | Hosting the Tomcat Web Server |
| Web Server | Apache Tomcat 10 | Serving the Java .war application |
| Orchestration | AWS CodePipeline | Managing the CI/CD workflow |
| Build | AWS CodeBuild | Compiling Java code & packaging artifacts |
| Deploy | AWS CodeDeploy | Automating deployment to EC2 instances |
| Scripting | Bash Shell | Lifecycle hooks (stop_server, start_server) |
| Language | Java 11 | Backend application logic |
We moved away from "ClickOps" to a structured pipeline:
graph LR
A[ Developer ] -->|Push Code| B( AWS CodeCommit / GitHub )
B -->|Trigger| C{ AWS CodePipeline }
C -->|Fetch| D[ AWS CodeBuild ]
D -->|Compile & Package| E[ Artifact: app.war ]
E -->|Deploy| F[ AWS CodeDeploy ]
F -->|Install & Restart| G[ EC2: Tomcat Server ]
style C fill:#FF9900,stroke:#232F3E,stroke-width:2px
style G fill:#E95420,stroke:#333,stroke-width:2px,color:white
Most of the hard work is scripted. Here is how the magic happens:
You push code to your repository. The buildspec.yml file tells CodeBuild exactly what to do.
- Provision an Ubuntu build environment.
- Fix Line Endings: Runs
dos2unixto ensure Windows-edited scripts work on Linux. - Compile: Runs
build.shto compile Java classes. - Package: Renames
ROOT.wartoapp.war.
CodeDeploy grabs the artifact and talks to the CodeDeploy Agent running on your EC2.
- ApplicationStop: Stops Tomcat service.
- Install: Drops
app.warinto/opt/tomcat/webapps/. - Permissions: Sets owner to
tomcat:tomcat. - ApplicationStart: Starts Tomcat service.
rules/: Custom scripts used by CodeDeploy.stop_server.sh: Safely stops the service.start_server.sh: Brings the app back to life.
buildspec.yml: The brain of the Build phase.appspec.yml: The blueprint for the Deployment phase.deployment_guide.md: [READ THIS FIRST!] A full manual on setting up the EC2 server and Pipeline.
Follow the detailed steps in deployment_guide.md to:
- Install Java 21 & Tomcat 10 on Ubuntu.
- Install CodeDeploy Agent.
- Configure IAM Roles.
Simply commit a change!
git add .
git commit -m "New feature: Super fast snakes! 🐍"
git push origin masterGo to the AWS CodePipeline Console and watch it turn green! ✅
Built with ❤️ during the DevOps Masterclass.