How to host the application.
- Create a new app in Google page
- Create a Service Account Key in Credentials page with role "Project - Owner" and save it as google-key.json
- Enable Cloud Run
- In repository create the Repository variable GOOGLE_PROJECT_ID the ID generated in step 1
- Create the Dockerfile
- Create the pipelines file in order to deploy docker image to Container Registry and deploy version
- Generate an API Key in Account Settings > Generate API Key
- Create a new app in Heroku page
- In Heroku app settings add the Config Vars SPRING_PROFILES_ACTIVE with value h2
- In repository create the Repository variables
HEROKU_API_KEY the Key generated in step 1
HEROKU_APP_NAME the Name of project generated in step 2 - Create the system.properties file with Java version (example: java.runtime.version=12)
- Create the pipelines file in order to push to heroku repository
- AWS > IAM > Groups > Create New Group
- Type "deploy_group" as Group Name
- Attach "AmazonS3FullAccess" and "AWSElasticBeanstalkFullAccess" Policies
- AWS > IAM > Users > Add User
- Type "ragde_java_api_deploy" as User Name
- Check "Programmatic access" Access type
- Check "deploy_group" to enroll this user with deploy Group
- Save Access key ID and Secret access key (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variable)
- AWS > S3 > Create bucket
- Type "ragdejavaapi" as Bucket Name (AWS_S3Bucket variable)
- AWS > Elastic Beanstalk > Create a New Application
- Type "RagdeJavaApi" as Application Name (AWS_ELASTIC_APP_NAME variable)
- In "RagdeJavaApi" create a new Web server environment called "Ragde-java-api" (AWS_ELASTIC_ENVIRONMENT variable)
- Type "ragde" as Domain name
- Choose Java as Platform
- Choose "Sample application"
- Once Created, in Configuration:
- Set SPRING_PROFILES_ACTIVE = aws on Application Configuration -> Software Configuration -> Environment Properties
- Create a new RDS database
- Choose mysql as Engine with max version
- Choose db.t2.micro as Instance class
- Set username and password
- Choose Delete when environment is deleted
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_S3Bucket
- AWS_ELASTIC_APP_NAME
- AWS_ELASTIC_ENVIRONMENT
- AWS_REGION (with value "us-east-2")
- Create a New Application in Elastic Beanstalk
- Choose Tomcat as Platform
- Choose Upload your code and upload a war
- Click on Configure more options
- Modify Environment settings (Name and Domain)
- Modify Database settings
- Choose mysql as Engine with max version
- Choose db.t2.micro as Instance class
- Set username and password
- Choose Delete when environment is deleted
- Click on Create app
- Set spring.profiles.active = aws on Application Configuration -> Software Configuration -> Environment Properties
- In EC2 > Security Groups select the Group that "Enable database access to Beanstalk application"
- In Inbound tap add a new rule Type: MYSLQ Source: My IP
- In AWS database create "ragde" database
- In application-sql-local.properties set:
spring.jpa.hibernate.ddl-auto = create
spring.datasource.url to point to remote AWS database - Run locally with ./gradlew bootRun -Dspring.profiles.active=sql-aws