This Spring Boot application is created to test deployments on AWS EC2 and ECS using GitHub Actions or AWS CodePipeline.
- Simple Spring Boot application with a home page - http://localhost:8080
- Thymeleaf template engine for rendering HTML views.
- Configured for deployment on AWS EC2 and ECS.
- Java 17
- Maven
- AWS account
- GitHub account
git clone https://github.com/hsiddhu2/springboot-helloworld.git
cd springboot-helloworldmvn clean installmvn spring-boot:runAccess the application at http://localhost:8080.
- Create an EC2 instance with the required configuration.
- SSH into the EC2 instance and install Java and Maven.
- Clone the repository on the EC2 instance.
- Build and run the application on the EC2 instance.
- Create an ECS cluster.
- Create a Dockerfile for the application.
- Build and push the Docker image to Amazon ECR.
- Create an ECS task definition and service.
- Deploy the application using the ECS service.
- Create a
.github/workflowsdirectory in the repository. - Add a GitHub Actions workflow file to build and deploy the application.
Example workflow file:
name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
- name: Build with Maven
run: mvn clean install
- name: Deploy to AWS EC2
run: |
# Add deployment steps here- Create a CodePipeline in the AWS Management Console.
- Add source, build, and deploy stages to the pipeline.
- Configure the pipeline to use the repository and build the application.
- Deploy the application to EC2 or ECS.
This project is licensed under the MIT License.
- Spring Boot documentation
- AWS documentation
- GitHub Actions documentation