|
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +This guide outlines the steps to deploy Linkking project backend web services to a production environment. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Deploy MySQL](#deploy-mysql) |
| 8 | +- [Environment Variables](#environment-variables) |
| 9 | +- [Deploy Backend](#deploy-backend) |
| 10 | + |
| 11 | +## Deploy MySQL |
| 12 | + |
| 13 | +1. **Setup MySQL Server:** |
| 14 | + - Install MySQL server on your hosting environment or use a cloud-based MySQL service provider. |
| 15 | + - We recommend [aiven.io](https://aiven.io) for cloud-based MySQL hosting. |
| 16 | + - Configure the MySQL server to allow remote connections if necessary. |
| 17 | + |
| 18 | +2. **Database Initialization:** |
| 19 | + - Execute the provided SQL script [data_sample.sql](/assets/databases/mysql/data_sample.sql) to initialize the |
| 20 | + database schema, necessary tables and sample data. |
| 21 | + |
| 22 | +## Environment Variables |
| 23 | + |
| 24 | +1. **Database Configuration:** |
| 25 | + - `DB_HOST`: Hostname or IP address of the MySQL server. |
| 26 | + - `DB_PORT`: Port number for MySQL server. |
| 27 | + - `DB_USERNAME`: Username for accessing the MySQL database. |
| 28 | + - `DB_PASSWORD`: Password for accessing the MySQL database. |
| 29 | + - `DB_NAME`: Name of the MySQL database (if using sample data, use `myecommerce` as the database name) |
| 30 | + - `DB_URL` with format `jdbc:mysql://<DB_USERNAME>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>?ssl-mode=REQUIRED` |
| 31 | + |
| 32 | +2. **Other Configurations:** |
| 33 | + - `API_URL`: Base URL for the deployed backend service (Assign API url after web service deployment). |
| 34 | + - `MAIL_USERNAME`: Email address for sending emails. |
| 35 | + - `MAIL_PASSWORD`: Password for the email address (Use |
| 36 | + an [app password](https://support.google.com/accounts/answer/185833?hl=en) if using Gmail). |
| 37 | + |
| 38 | +## Deploy Backend |
| 39 | + |
| 40 | +This guide will help you deploy the Linkking project backend web services to [Render](https://render.com/). |
| 41 | + |
| 42 | +1. **Prerequisites:** |
| 43 | + - **Docker Desktop:** Ensure you have Docker Desktop installed on your system. |
| 44 | + - **Docker Hub Account:** Create an account on [Docker Hub](https://hub.docker.com/) if you don't have one already. |
| 45 | + |
| 46 | +2. **Build JAR files:** |
| 47 | + - Run the following command to build the JAR file: |
| 48 | + ```bash |
| 49 | + mvn clean -DskipTests package |
| 50 | + ``` |
| 51 | + - You can also run this command via IntelliJ IDEA by right-clicking on the project and |
| 52 | + selecting `Run Maven` -> `New Goal...` -> `clean -DskipTests package`. |
| 53 | + |
| 54 | +3. **Build Docker Image and Deploy to Render:** |
| 55 | + |
| 56 | + - For proper instructions, please refer to this blog |
| 57 | + post: [How to host a Spring Boot application for free with Render](https://hostingtutorials.dev/blog/free-spring-boot-host-with-render) (You may skip to the **Building your docker image** section). |
| 58 | + - Example commands used from above blog post (Assume you already in `backend/` directory): |
| 59 | + ```bash |
| 60 | + docker build -t linkking . |
| 61 | + docker tag linkking letiendat1002/linkking |
| 62 | + docker login -u letiendat1002 |
| 63 | + docker push letiendat1002/linkking:latest |
| 64 | + ``` |
0 commit comments