Skip to content

Commit

Permalink
Update documentation (#191)
Browse files Browse the repository at this point in the history
* Update documentation and fix keep-alive scheduler

* Update documentation
  • Loading branch information
letiendat1002 committed Mar 11, 2024
1 parent acc83dd commit 8a4edea
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
15 changes: 11 additions & 4 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Spring Security](https://spring.io/projects/spring-security)
- [Spring Web](https://spring.io/projects/spring-web)
- [Spring Test](https://spring.io/guides/gs/testing-web/)
- More details please refer to [pom.xml](pom.xml)

## Requirements

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

## Documentation

1. [Connect to database](docs/ConnectDatabase.md)
2. [APIs](docs/APIs.md)
3. [Role & Permission](docs/RolePermission.md)
1. [Docs folder](docs)
2. [Connect to database](docs/ConnectDatabase.md)
3. [APIs](docs/APIs.md)
4. [Role & Permission](docs/RolePermission.md)
5. [Deployment](docs/Deployment.md)

**Notice**:
- To initiate the backend properly, please open this project in the `backend/` folder not the root `e-commerce/` folder.
- 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`).
- 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`.
64 changes: 64 additions & 0 deletions backend/docs/Deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Deployment Guide

This guide outlines the steps to deploy Linkking project backend web services to a production environment.

## Table of Contents

- [Deploy MySQL](#deploy-mysql)
- [Environment Variables](#environment-variables)
- [Deploy Backend](#deploy-backend)

## Deploy MySQL

1. **Setup MySQL Server:**
- Install MySQL server on your hosting environment or use a cloud-based MySQL service provider.
- We recommend [aiven.io](https://aiven.io) for cloud-based MySQL hosting.
- Configure the MySQL server to allow remote connections if necessary.

2. **Database Initialization:**
- Execute the provided SQL script [data_sample.sql](/assets/databases/mysql/data_sample.sql) to initialize the
database schema, necessary tables and sample data.

## Environment Variables

1. **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, use `myecommerce` as the database name)
- `DB_URL` with format `jdbc:mysql://<DB_USERNAME>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>?ssl-mode=REQUIRED`

2. **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](https://support.google.com/accounts/answer/185833?hl=en) if using Gmail).

## Deploy Backend

This guide will help you deploy the Linkking project backend web services to [Render](https://render.com/).

1. **Prerequisites:**
- **Docker Desktop:** Ensure you have Docker Desktop installed on your system.
- **Docker Hub Account:** Create an account on [Docker Hub](https://hub.docker.com/) if you don't have one already.

2. **Build JAR files:**
- Run the following command to build the JAR file:
```bash
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`.

3. **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](https://hostingtutorials.dev/blog/free-spring-boot-host-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):
```bash
docker build -t linkking .
docker tag linkking letiendat1002/linkking
docker login -u letiendat1002
docker push letiendat1002/linkking:latest
```

0 comments on commit 8a4edea

Please sign in to comment.