Skip to content

Commit

Permalink
Update official documentation link to README
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Sep 22, 2024
1 parent 36a458b commit 0e6df07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 196 deletions.
101 changes: 3 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,105 +103,10 @@ Luckily, we now have a demo site: [FBA UI](https://fba.xwboy.top/)
└─📁 deploy---------------- # Server deployment
```

## Local development
## Local development / Docker deployment

* Python: 3.10+
* Mysql: 8.0+
* Redis: The latest stable version is recommended
* Nodejs: 14.0+

### Backend

1. Enter the `backend` directory

```shell
cd backend
```

2. Install the dependencies

```shell
pip install -r requirements.txt
```

3. Create a database `fba` with utf8mb4 encoding.
4. Install and start Redis
5. Create a `.env` file in the `backend` directory.

```shell
touch .env
cp .env.example .env
```

6. Modify the configuration files `core/conf.py` and `.env` as needed.
7. database migration [alembic](https://alembic.sqlalchemy.org/en/latest/tutorial.html)

```shell
# Generate the migration file
alembic revision --autogenerate
# Execute the migration
alembic upgrade head
```

8. Start celery worker, beat and flower

```shell
celery -A app.task.celery worker -l info
# Scheduled tasks (optional)
celery -A app.task.celery beat -l info
# Web monitor (optional)
celery -A app.task.celery flower --port=8555 --basic-auth=admin:123456
```

9. [Initialize test data](#test-data) (Optional)
10. Start fastapi service
```shell
# Help
fastapi --help
# Dev mode
fastapi dev main.py
```

11. Open a browser and visit: http://127.0.0.1:8000/api/v1/docs

### Front end

Jump to [fastapi_best_architecture_ui](https://github.com/fastapi-practices/fastapi_best_architecture_ui) View details

---

### Docker Deployment

> [!WARNING]
>
> Default port conflicts: 8000, 3306, 6379, 5672.
>
> It is recommended to shut down local services: mysql, redis, rabbitmq... before deployment.

1. Go to the `deploy/backend/docker-compose` directory, and create the environment variable file `.env`.

```shell
cd deploy/backend/docker-compose
touch .env.server ../../../backend/.env
cp .env.server ../../../backend/.env
```

2. Modify the configuration files `backend/core/conf.py` and `.env` as needed.
3. Execute the one-click startup command

```shell
docker-compose up -d --build
```

4. Wait for the command to complete.
5. Open a browser and visit: http://127.0.0.1:8000/api/v1/docs
For more details, please check
the [official documentation](https://fastapi-practices.github.io/fastapi_best_architecture_docs/)

## Test data

Expand Down
100 changes: 2 additions & 98 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,105 +98,9 @@ mvc 架构作为常规设计模式,在 python web 中也很常见,但是三
└─📁 deploy---------------- # 服务器部署
```

## 本地开发
## 本地开发 / Docker 部署

* Python 3.10+
* Mysql 8.0+
* Redis 推荐最新稳定版
* Nodejs 14.0+

### 后端

1. 进入 `backend` 目录

```shell
cd backend
```

2. 安装依赖包

```shell
pip install -r requirements.txt
```

3. 创建一个数据库 `fba`,选择 utf8mb4 编码
4. 安装并启动 Redis
5. 在 `backend` 目录下创建 `.env` 文件

```shell
touch .env
cp .env.example .env
```

6. 按需修改配置文件 `core/conf.py``.env`
7. 数据库迁移 [alembic](https://alembic.sqlalchemy.org/en/latest/tutorial.html)

```shell
# 生成迁移文件
alembic revision --autogenerate
# 执行迁移
alembic upgrade head
```

8. 启动 celery worker, beat 和 flower

```shell
celery -A app.task.celery worker -l info
# 定时任务(可选)
celery -A app.task.celery beat -l info
# web 监控(可选)
celery -A app.task.celery flower --port=8555 --basic-auth=admin:123456
```

9. [初始化测试数据](#测试数据)(可选)
10. 启动 fastapi 服务
```shell
# 帮助
fastapi --help
# 开发模式
fastapi dev main.py
```

11. 打开浏览器访问:http://127.0.0.1:8000/api/v1/docs

### 前端

跳转 [fastapi_best_architecture_ui](https://github.com/fastapi-practices/fastapi_best_architecture_ui) 查看详情

---

### Docker 部署

> [!WARNING]
>
> 默认端口冲突:8000,3306,6379,5672
>
> 建议在部署前关闭本地服务:mysql,redis,rabbitmq...

1. 进入 `deploy/backend/docker-compose` 目录,创建环境变量文件`.env`

```shell
cd deploy/backend/docker-compose
touch .env.server ../../../backend/.env
cp .env.server ../../../backend/.env
```

2. 按需修改配置文件 `backend/core/conf.py``.env`
3. 执行一键启动命令

```shell
docker-compose up -d --build
```

4. 等待命令执行完成
5. 打开浏览器访问:http://127.0.0.1:8000/api/v1/docs
更多详情请查看 [官方文档](https://fastapi-practices.github.io/fastapi_best_architecture_docs/)

## 测试数据

Expand Down

0 comments on commit 0e6df07

Please sign in to comment.