-1

I'm working with a startup to build an app. I've been studying CS for 2 years, so I'm new to lots of things. For our app we have a ReactJS front-end, Express back-end, and MySQL database. Currently it's deployed on AWS Elastic Beanstalk in a NodeJS environment. I configured it to run react-scripts build after it's been deployed. It's serving the static React-generated files through the Express server (bad idea, I know). This has worked for a while, but now the instance is running out of memory when trying to build.

I've been looking into Docker as a better solution (I've never used Docker before this week), and now I have a local development setup with 3 containers: a MySQL container, a Node container running the backend, and an Alpine container just running react-scripts start. The front-end is using a proxy to connect to the backend. This is all working fine locally (except that my backend container can't connect to the Internet so an external API is broken), but I have no idea how to deploy this correctly to AWS.

With Elastic Beanstalk is there a way for me to build and deploy a single Docker container with the pre-built React front-end, configure Nginx to serve those static files, and then pass all /api requests to the Express server? I'm using RDS for the database, so I don't feel like I need to deploy another container for MySQL.

I don't expect you guys to solve my problem, but I'd appreciate being pointed in the right direction. Maybe I'm going about this completely the wrong way.

Kollin Murphy
  • 395
  • 1
  • 3
  • 7

1 Answers1

0

React App:

I suggest you deploy your react application on AWS Amplify. you can find resources on how to deploy on the internet very easily.

MySQL

You can host your MySQL database on an EC2 instance or use any other hosted service for the database.

Express App

Now you can host your express app on EBS using the docker platform. You can also get the resources for this on the internet.

===========================================================================

Now add your express app endpoint in AWS Amplify's environment to use it with react app. Add MySQL URL to EBS's environment to use it with Express App.

Note: AWS amplify serves your app on HTTPS so you have to enable SSL on EBS also. You can do it with the AWS certificate manager by getting an SSL certificate and attaching it to the EBS.

It will be easy if the domain is handled by Route53 but again you can also achieve this with any domain service provider.

It is recommended that you should migrate your domain to Route 53, as you will get more control and also many other benefits. Refer this answer: https://stackoverflow.com/a/38225802/9323655

Hope my answer will guide you in the right direction.

ShuLaPy
  • 151
  • 7