This is a personal project to practice my skills in React, Spring Boot, JPQL, Docker and k8s.
- AWS S3(frontend) + AWS ECS(backend)
- AWS S3(frontend) + AWS EC2(backend)
- Reference: Spring Boot + Angular + MYSQL on AWS ECS Fargate | AWS ECS Fargate
- Reference: Full-Stack Spring Boot with Angular CRUD API application with MYSQL on AWS | AWS EC2 | AWS S3 | RDS
- Create MySQL database container in ECS Fargate task
- Modify database link in application.properties to the previous created MySQL endpoint
- Generate .war file:
mvn clean install -DskipTests=true
- Build an image(repo here) for the api:
docker build -t johnnyhohohohohoho/johnny-bookstore:1.0 .
- Push to docker hub:
docker push johnnyhohohohohoho/johnny-bookstore:1.0
or AWS ECR - In AWS ECS, setup container for the backend by coping the image link(docker.io/johnnyhohohohohoho/johnny-bookstore:1.0) in docker hub
- For the React frontend, modify the request endpoint and build a docker image for it
- Push the frontend image to docker hub or ECR
- In AWS ECS, setup container for the frontend image
- Reference: Spring Boot + Angular + MYSQL on AWS ECS Fargate | AWS ECS Fargate
- Github: shameed1910 / springboot-angular-aws-fargate
- Choose an AMI (Amazon Machine Image) for EC2 instance in AWS Management Console
- Choose EC2 instance type
- In security group section, click Add Rule button to add a rule allow TCP traffic on port 8080
- Store the key-pair .pem for accessing the EC2 instance
- Modify database link in application.properties to the cloud database. A better way is to separate *-dev.properties and *-prod.properties file for different database enpoints
- Generate .war file:
mvn clean install -DskipTests=true
or generate .jar file by./gradlew bootJar
- Create a deploy.sh file to copy the executable jar/war to the ec2 using the .pem file to connect to ec2
- Include ssh command to connect to the EC2 (the command would be provided by the AWS EC2 setup page) in deploy.sh
- Kill the previous running process
- Restart the updated project by
java -jar xxxx-SNAPSHOOT.jar / xxxx-SNAPSHOOT.war
- Reference: Deploying/Hosting Spring Boot Applications on AWS EC2
- Reference: Full-Stack Spring Boot with Angular CRUD API application with MYSQL on AWS | AWS EC2 | AWS S3 | RDS
- Github: shameed1910 / springboot-crud-api
- Modify the api call url to the cloud api call endpoint
npm install
npm run build
- upload the content in build folder to the AWS S3 bucket
- In the bucket Properties section, choose "Static website hosting" and save