优化auth服务配置:添加阿里云镜像源、热重载和日志实时输出
This commit is contained in:
parent
be3b2d1351
commit
73549335ab
@ -1,9 +1,9 @@
|
|||||||
FROM python:3.13-slim
|
FROM python:3.13-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /home/booksystem/auth
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||||||
|
|
||||||
COPY .. .
|
COPY .. .
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ app = FastAPI()
|
|||||||
@app.get("/")
|
@app.get("/")
|
||||||
# 声明装饰器函数
|
# 声明装饰器函数
|
||||||
async def home():
|
async def home():
|
||||||
return {"message": "Hello World!"}
|
return {"message": "Hello World!!!"}
|
||||||
|
|
||||||
# 如果使用命令行启动,使用uvicorn 文件名:app --reload启动即可,下面命令就不用写
|
# 如果使用命令行启动,使用uvicorn 文件名:app --reload启动即可,下面命令就不用写
|
||||||
# 如果写下面的命令,就不需要命令行启动了,直接用IDE运行即可
|
# 如果写下面的命令,就不需要命令行启动了,直接用IDE运行即可
|
||||||
@ -15,4 +15,4 @@ if __name__ == "__main__":
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
import os
|
import os
|
||||||
name = f"{os.path.splitext(os.path.basename(os.path.abspath(__file__)))[0]}:app"
|
name = f"{os.path.splitext(os.path.basename(os.path.abspath(__file__)))[0]}:app"
|
||||||
uvicorn.run(name, host="0.0.0.0", port=8000)
|
uvicorn.run(name, host="0.0.0.0", port=8000, reload=True, reload_dirs=["."])
|
||||||
@ -1,5 +1,3 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# 数据库
|
# 数据库
|
||||||
postgres:
|
postgres:
|
||||||
@ -111,7 +109,11 @@ services:
|
|||||||
- "${AUTH_PORT}:8000"
|
- "${AUTH_PORT}:8000"
|
||||||
volumes:
|
volumes:
|
||||||
# 挂载宿主机代码目录到容器,实现实时同步
|
# 挂载宿主机代码目录到容器,实现实时同步
|
||||||
- ../backend/auth:/app
|
- type: bind
|
||||||
|
source: ../backend/auth
|
||||||
|
target: ${CONTAINER_BASE_PATH}/auth
|
||||||
|
bind:
|
||||||
|
create_host_path: true
|
||||||
environment:
|
environment:
|
||||||
- DB_HOST=postgres
|
- DB_HOST=postgres
|
||||||
- DB_PORT=5432
|
- DB_PORT=5432
|
||||||
@ -121,6 +123,8 @@ services:
|
|||||||
- REDIS_HOST=redis
|
- REDIS_HOST=redis
|
||||||
- REDIS_PORT=6379
|
- REDIS_PORT=6379
|
||||||
- REDIS_PASSWORD=${REDIS_PASSWORD}
|
- REDIS_PASSWORD=${REDIS_PASSWORD}
|
||||||
|
- PYTHONUNBUFFERED=1 # 禁用 Python 输出缓存,确保日志实时显示
|
||||||
|
- UVICORN_RELOAD_DIRS=/app # 辅助指定热重载监听目录
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- redis
|
- redis
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user