Deploying Spring Boot to AWS ECS with GitHub Actions
Architecture Overview
Spring Boot AWS ECS
Steps to Deploy
1. Dockerize the App
dockerfileFROM openjdk:17ARG JAR_FILE=target/*.jarCOPY ${JAR_FILE} app.jarENTRYPOINT ["java", "-jar", "app.jar"]
2. Push to ECR (Elastic Container Registry)
bashaws ecr get-login-password | docker login ...docker build -t my-app .docker tag my-app:latest <your-ecr-url>docker push <your-ecr-url>
3. Define ECS Task
Use Fargate or EC2-based task with load balancer.
4. Automate with GitHub Actions
yamlname: Deploy to ECSon:push:branches: [ main ]jobs:build-and-deploy:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v3- uses: docker/setup-buildx-action@v2- uses: docker/build-push-action@v4with:context: .push: truetags: ${{ secrets.ECR_URI }}:latest
Done â
You now have a cloud-deployed Spring Boot app, auto-deployed on every push to main
.