This guide outlines the steps to deploy Linkking project backend web services to a production environment.
-
Setup MySQL Server:
- Install MySQL server on your hosting environment or use a cloud-based MySQL service provider.
- We recommend aiven.io for cloud-based MySQL hosting.
- Configure the MySQL server to allow remote connections if necessary.
-
Database Initialization:
- Execute the provided SQL script data_sample.sql to initialize the database schema, necessary tables and sample data.
-
Database Configuration:
DB_HOST
: Hostname or IP address of the MySQL server.DB_PORT
: Port number for MySQL server.DB_USERNAME
: Username for accessing the MySQL database.DB_PASSWORD
: Password for accessing the MySQL database.DB_NAME
: Name of the MySQL database (if using sample data, usemyecommerce
as the database name)DB_URL
with formatjdbc:mysql://<DB_USERNAME>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>?ssl-mode=REQUIRED
-
Other Configurations:
API_URL
: Base URL for the deployed backend service (Assign API url after web service deployment).MAIL_USERNAME
: Email address for sending emails.MAIL_PASSWORD
: Password for the email address (Use an app password if using Gmail).
This guide will help you deploy the Linkking project backend web services to Render.
-
Prerequisites:
- Docker Desktop: Ensure you have Docker Desktop installed on your system.
- Docker Hub Account: Create an account on Docker Hub if you don't have one already.
-
Build JAR files:
- Run the following command to build the JAR file:
mvn clean -DskipTests package
- You can also run this command via IntelliJ IDEA by right-clicking on the project and
selecting
Run Maven
->New Goal...
->clean -DskipTests package
.
- Run the following command to build the JAR file:
-
Build Docker Image and Deploy to Render:
- For proper instructions, please refer to this blog post: How to host a Spring Boot application for free with Render (You may skip to the Building your docker image section).
- Example commands used from above blog post (Assume you already in
backend/
directory):docker build -t linkking . docker tag linkking letiendat1002/linkking docker login -u letiendat1002 docker push letiendat1002/linkking:latest