简体   繁体   中英

Deploying React App with Spring Boot REST API in AWS BeanStalk

I'm trying to deploy 2 instances (front and back end) separately. Currently, the back end which is the REST API using SpringBoot was successfully deployed in BeanStalk as a.jar file. Now, I have never deploy a front end app (in my case my React app) separately in AWS BeanStalk and I have been doing my research but I'm stuck. How do I "compile" my React app and deploy it in BeanStalk like I did with the back end?

I got it, for anyone in the future needs help with this, all you have to do just follow these steps:

  1. Create a bucket and allow complete public access
  2. Go to permission -> bucket policy -> add this script
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::(name-of-your-bucket)/*"
        }
    ]
} 
  1. add this to your package.json under scripts

"deploy": "aws s3 cp --recursive./build s3://(your-bucket-name)",

  1. execute npm run build in terminal

  2. execute aws s3 cp --recursive./build s3://(your-bucket-name) in terminal (you are uploading your build files inside the build folder to s3)

  3. go to properties -> static web hosting -> point out the index.html if you use that -> click the end point

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM