Deploying a SpringBoot-React project on AWS EC2

At SSAFY, they gave us 1 EC2 instance (no AWS Console access either....) so I deployed in a similar manner to the previous timearrow-up-right

  • Port 80 - React.js frontend serve

  • Port 8000 - SpringBoot backend serve

Frontend Deployment

  • The Frontend deployment is the same method as when deploying the Django-Vue project, so follow steps 1-9 from this linkarrow-up-right

    • Of course, when installing required packages, skip steps that are unrelated to this project, such as Python installation!

Backend Deployment

1. Install Java

1-1. Install

sudo apt-get install openjdk-11-jdk
  • This command also installs the openjdk-11-jre package which contains the Java runtime environment!

1-2. Check version

2. Install Maven

2-1. Install Maven

2-2. Install maven-wrapper

2-3. Build

Navigate to the location where mvnw is visible and execute the following command

  • Executing this command cleans the previous build records of the mvnw file in the current directory and builds a new package

    • This takes a long time! FYI!

  • If you see the BUILD SUCCESS message, it was successful!

3. Execute the .jar file

3-1. Execute

Go into the target directory and execute the following command

  • nohup

    • A program in Linux/Unix that runs shell script files (*.sh) in daemon mode

      • Keeps running even when the terminal session is disconnected

  • Adding & after the command means separating the current command from other commands!

    • You can execute other commands while the server is running from the jar file

    • The jar file runs in the background!

4. Grant MySQL external access permissions

+

Redeployment

As I wrote in the previous deployment notes, this is very inefficient!!! Planning to apply CI/CD!!!

-> Applied it!arrow-up-right

When backend is modified

1. Check the running port

2. Kill the port

3. Pull the project via git

4. build

5. run

When frontend is modified

Last updated