Skip to content

Commit 8a4edea

Browse files
Update documentation (#191)
* Update documentation and fix keep-alive scheduler * Update documentation
1 parent acc83dd commit 8a4edea

File tree

2 files changed

+75
-4
lines changed

2 files changed

+75
-4
lines changed

backend/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Spring Security](https://spring.io/projects/spring-security)
1010
- [Spring Web](https://spring.io/projects/spring-web)
1111
- [Spring Test](https://spring.io/guides/gs/testing-web/)
12+
- More details please refer to [pom.xml](pom.xml)
1213

1314
## Requirements
1415

@@ -20,10 +21,16 @@
2021
1. [MySQL Scripts](assets/databases/mysql)
2122
2. [Database Design](assets/images/database/database_design.png)
2223
3. [Spring Security Architecture](assets/images/security)
23-
4. [Documentation](docs)
2424

2525
## Documentation
2626

27-
1. [Connect to database](docs/ConnectDatabase.md)
28-
2. [APIs](docs/APIs.md)
29-
3. [Role & Permission](docs/RolePermission.md)
27+
1. [Docs folder](docs)
28+
2. [Connect to database](docs/ConnectDatabase.md)
29+
3. [APIs](docs/APIs.md)
30+
4. [Role & Permission](docs/RolePermission.md)
31+
5. [Deployment](docs/Deployment.md)
32+
33+
**Notice**:
34+
- To initiate the backend properly, please open this project in the `backend/` folder not the root `e-commerce/` folder.
35+
- To run the project locally, please refer to [Connect to database](docs/ConnectDatabase.md) for more details and remember to change `spring.profiles.active` in [application.yml](src/main/resources/application.yml) from `prod` to `dev` (default value is `prod`).
36+
- To deploy the project, please refer to [Deployment](docs/Deployment.md) for more details and remember to change `spring.profiles.active` in [application.yml](src/main/resources/application.yml) from `dev` to `prod`.

backend/docs/Deployment.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

Comments
 (0)