Fullstack Application — React (TypeScript) frontend, Axios HTTP client, Deno middleware, Spring Boot Java backend, OkHttp client, and MySQL (AWS RDS - Aurora) service.
Docker's example of this stack using React, Java, and MySQL
- Create React App (TypeScript)
- TypeScript
- React Router
- Material UI
- Emotion Styled Components
- Recoil
- Swiper
- Axios HTTP
- AWS Amplify - Hosting
- AWS Amplify - Authentication
- AWS RDS - Aurora
- AWS Virtual Private Cloud
- AWS Elastic Container Registry
- AWS Elastic Kubernetes Service
- AWS EC2
- AWS Elastic Load Balancing
- Visual Studio Code
- Intellij Idea
- Yarn
- Deno
- Gradle
- Docker
- Postman
- MySQL Community Server
- MySQL Workbench
- Kubernetes Dashboard
git rm -r --cached .git reset --hard <COMMIT_ID>gshield secret scan repocd frontend
yarn prettier --write .cd middleware
yarn prettier --write .cd frontend
yarn addcd frontend
yarn installcd middleware
yarn installcd frontend
yarn cache cleancd middleware
yarn cache cleancd frontend
yarn plugin import interactive-toolscd frontend
yarn upgrade-interactivecd middleware
yarn plugin import interactive-toolscd middleware
yarn upgrade-interactiveAccess the frontend code by opening a command line in the root of this project and changing to the frontend folder.
cd frontend-
Install Node LTS for the proper operating system
-
Enable Corepack for installing Yarn
corepack enable -
Install [Yarn](corepack prepare yarn@stable --activate) for installing and managing
package.jsondependenciescorepack prepare yarn@stable --activate
-
Upgrade Yarn to the latest stable version
yarn set version stable -
Install
package.jsondependencies for projectyarn install
-
Rename the
example.envfile to.envfor Yarn and Docker- This is a security measure for reducing commits with secrets
-
Install Visual Studio Code editor
-
In Visual Studio Code terminal build the React TypeScript application into a bundle
yarn build
-
Start project
yarn start
For more examples and information on Node JavaScript Docker builds, reference the Node JavaScript Documentation
-
Docker build command
docker build -t spring-react-typescript-rest/frontend .
-
Docker run command
Start Container (Publish):
docker run -p 3000:3000 spring-react-typescript-rest/frontend
-
Docker login command
Login:
docker login
-
Docker tag command
Tag:
docker tag spring-react-typescript-rest/frontend <DOCKER_USERNAME>/spring-react-typescript-rest-frontend:latest
-
Docker push command
Push:
docker push <DOCKER_USERNAME>/spring-react-typescript-rest-frontend:latest
- Install AWS Amplify CLI to setup Amplify functionality
npm install -g @aws-amplify/cli-
Create a CLI based Access Id and Secret Key for an AWS IAM User
-
Configure the AWS Amplify configuration
amplify configure-
Initialize the AWS Amplify project configuration
-
If the initialization does not complete, rename the
.gitignore, make sure to copy the contents of the initial.gitignore, into the file Amplify generates
Access the middleware code by opening a command line in the root of this project and changing to the middleware folder.
cd middleware-
Start project
deno run --allow-net --allow-read --allow-env --allow-run --watch=routes/ main.ts
For more examples and information on Spring Boot Docker builds, reference the Spring Framework Documentation.
-
Docker build command
docker build -t spring-react-typescript-rest/middleware .
-
Docker run command
Start Container (Publish):
docker run -p 4040:4040 spring-react-typescript-rest/middleware
Start Container (Interactively & pseudo-TTY) :
docker run spring-react-typescript-rest/middleware -it 4040:4040
-
Docker login command
Login:
docker login
-
Docker tag command
Tag:
docker tag spring-react-typescript-rest/middleware <DOCKER_USERNAME>/spring-react-typescript-rest-middleware:latest
-
Docker push command
Push:
docker push <DOCKER_USERNAME>/spring-react-typescript-rest-middleware:latest
-
Add the Powershell AWS tools for ECR, to begin setting up registry permissions
Install-Module -Name AWS.Tools.ECR
-
You can reference the Getting started documentation for implementing access configuration (Make sure the repository is established with a non-root account)
-
Pipe AWS password to Docker login command
(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com -
Docker tag command
Tag:
docker tag spring-react-typescript-rest/middleware <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/middleware:latest
-
Docker push command
Push:
docker push <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/middleware:latest
Access the backend code by opening a command line in the root of this project and changing to the backend folder.
cd backend-
In Powershell running as admin, enable Windows Subsystem for Linux
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
-
In Powershell running as admin, enable Virtual Machine feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
-
In Powershell running as admin, install WSL to the second version
wsl --install Ubuntu-22.04
-
Install Hyper terminal
-
In Hyper click the hamburger menu -> edit -> preferences -> update the two lines by pasting or typing so they reflect
shell: 'C:\\Windows\\System32\\wsl.exe'andshellArgs: [~] -
In Hyper terminal upgrade WSL (Ubuntu)
sudo apt update && sudo apt upgrade -y -
Install Unzip in WSL (Ubuntu)
sudo apt-get install unzip -y -
Install Zip in WSL (Ubuntu)
sudo apt-get install zip -y -
Install chocolatey
-
Install SDKMan with chocolatey (Ubuntu)
curl -s "https://get.sdkman.io" | bash
-
Configure SDKMan in your terminal command line
source "$HOME/.sdkman/bin/sdkman-init.sh"
-
Install Gradle
sdk install gradle 8.1.1
-
Create configuration in IntelliJ IDEA or reference the
SpringReactTypeScriptREST.run.xmlfile in thebackendfolder and start the application with IntelliJ IDEA<component name="ProjectRunConfigurationManager"> <configuration default="false" name="SpringReactTypeScriptREST" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true"> <option name="ACTIVE_PROFILES" value="dev" /> <module name="spring-react-typescript-rest-backend.main" /> <option name="SPRING_BOOT_MAIN_CLASS" value="com.springreacttypescriptrest.backend.SpringReactTypeScriptREST" /> <extension name="software.aws.toolkits.jetbrains.core.execution.JavaAwsConnectionExtension"> <option name="credential" /> <option name="region" /> <option name="useCurrentConnection" value="false" /> </extension> <method v="2"> <option name="Make" enabled="true" /> </method> </configuration> </component>
-
Rename the
application-dev.propertiesandapplication-prod.propertiesfiles toapplication-development.propertiesandapplication-produdction.propertiesfor Gradle and Docker- This is a security measure for reducing commits with secrets
-
Install IntelliJ IDEA IDE
-
In IntelliJ IDEA terminal build the Spring Boot application into a JAR
./gradlew build
For more examples and information on Spring Boot Docker builds, reference the Spring Framework Documentation.
-
Docker build command
docker build -t spring-react-typescript-rest/backend .
-
Docker run command
Start Container (Publish):
docker run -p 8080:8080 spring-react-typescript-rest/backend
Start Container (Interactively & pseudo-TTY) :
docker run spring-react-typescript-rest/backend -it 8080:8080
-
Docker login command
Login:
docker login
-
Docker tag command
Tag:
docker tag spring-react-typescript-rest/backend <DOCKER_USERNAME>/spring-react-typescript-rest-backend:latest
-
Docker push command
Push:
docker push <DOCKER_USERNAME>/spring-react-typescript-rest-backend:latest
-
Add the Powershell AWS tools for ECR, to begin setting up registry permissions
Install-Module -Name AWS.Tools.ECR
-
You can reference the Getting started documentation for implementing access configuration (Make sure the repository is established with a non-root account)
-
Pipe AWS password to Docker login command
(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin aws_account_id.dkr.ecr.region.amazonaws.com -
Docker tag command
Tag:
docker tag spring-react-typescript-rest/backend <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/backend:latest
-
Docker push command
Push:
docker push <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/backend:latest
-
Install AWS CLI to setup AWS functionality
-
Validate successful installation AWS CLI
aws --version
-
Create a CLI based Access Id and Secret Key for an AWS IAM User
-
Prepare the following values for the configuration stage of the AWS CLI, the region can be found on this documentation page, reference the column with the label, "region".
-
Access Key: <ACCESS_KEY>
-
Secret Key: <SECRET_KEY>
-
Region:
aws configure- Add any required permissions to the IAM User for which the AWS CLI configuration was established with
- Install MySQL Community Server
- Install MySQL Workbench
-
Install Helm with chocolatey
choco install kubernetes-helm
-
Validate successful installation of Helm
helm version
-
Create Helm chart with chocolatey
helm create <CHART_NAME>
-
Install Kubernetes CLI with chocolatey
choco install kubernetes-cli
-
Validate successful installation of KubeCTL
kubectl version --client
-
Install EKS Kubernetes CLI with chocolatey
chocolatey install -y eksctl
-
Upgrade EKS Kubernetes CLI
chocolatey upgrade -y eksctl
-
Validate successful installation of EKSCTL
eksctl version
-
Create a cluster for your application with KubeCTL and EKSCTL
eksctl create cluster --name=Cluster --version=1.27 --nodes=1 --node-type=t3.medium
-
Validate successful EKS cluster creation with KubeCTL
kubectl get nodes
-
Create a cluster for your application with KubeCTL and EKSCTL
eksctl create nodegroup --cluster=Cluster --region=<REGION> --name=Nodegroup --node-ami-family=AmazonLinux2 --node-type=t3.medium --nodes=1 --nodes-min=1 --nodes-max=3
-
Validate successful EKS cluster node group creation with KubeCTL
kubectl get nodes
- Access AWS Certificate Manager (ACM) in AWS Console
- Request a public certificate for the domain the application will use
- Add the domain and the certificate's arn to the
ingress.yamlfile
-
Change to kubernetes folder within the backend folder
cd backend/kubernetes -
Update and apply namespace file with KubeCTL
kubectl apply -f namespace.yaml
-
Validate successful EKS cluster namespace creation with KubeCTL
kubectl get namespaces --show-labels
-
Update and apply deployment file with KubeCTL
kubectl apply -f deployment.yaml
-
Validate successful EKS cluster deployment creation with KubeCTL
kubectl get deployments --show-labels --namespace=backend-namespace
-
Update and apply service file/s with KubeCTL
kubectl apply -f service.yaml kubectl apply -f service-secure.yaml
-
Validate successful EKS cluster service creation with KubeCTL
kubectl get services --show-labels --namespace=backend-namespace
-
Update and apply ingress file/s with KubeCTL
kubectl apply -f ingress.yaml kubectl apply -f ingress-secure.yaml
-
Validate successful EKS cluster ingress creation with KubeCTL
kubectl get ingress --show-labels --namespace=backend-namespace
-
Rollout restart deployment with KubeCTL to pull new image
kubectl rollout restart deployment/backend-deployment --namespace=backend-namespace
-
Validate successful EKS cluster deployment pod restarts with KubeCTL
kubectl get pods --namespace=backend-namespace
-
Get AWS Region IAM Policy JSON
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.7/docs/install/iam_policy.json
-
Create AWS Load Balancer Controller IAM Policy
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam_policy.json
-
Create AWS EKS OIDC Provider
eksctl utils associate-iam-oidc-provider --region=<REGION> --cluster=Cluster --approve
-
Create AWS Load Balancer Controller IAM Role
eksctl create iamserviceaccount --cluster=Cluster --namespace=kube-system --name=aws-load-balancer-controller --role-name AmazonEKSLoadBalancerControllerRole --attach-policy-arn=arn:aws:iam::<ACCOUNT_ID>:policy/AWSLoadBalancerControllerIAMPolicy --approve
-
ADD AWS Load Balancer Controller Helm Repository
helm repo add eks https://aws.github.io/eks-charts
-
Update AWS Load Balancer Controller Helm Repository
helm repo update eks
-
Install AWS Load Balancer Controller with Helm
helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=Cluster --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
-
Validate successful AWS Load Balancer Controller deployment with KubeCTL
kubectl get deployment -n kube-system aws-load-balancer-controller
© 2023 Spring React TypeScript REST released via MIT license. Information on this license can be viewed as it applies to this repository on GitHub at Spring React TypeScript REST License.