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