From 73549335abc5dc077626cf21ee9b5ef9828440c1 Mon Sep 17 00:00:00 2001 From: jayhgq Date: Wed, 25 Feb 2026 15:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96auth=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=9A=E6=B7=BB=E5=8A=A0=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E4=BA=91=E9=95=9C=E5=83=8F=E6=BA=90=E3=80=81=E7=83=AD=E9=87=8D?= =?UTF-8?q?=E8=BD=BD=E5=92=8C=E6=97=A5=E5=BF=97=E5=AE=9E=E6=97=B6=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/auth/Dockerfile | 4 ++-- backend/auth/app.py | 4 ++-- docker-compose/docker-compose.yml | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/auth/Dockerfile b/backend/auth/Dockerfile index b9bc4c7..bf91b8a 100644 --- a/backend/auth/Dockerfile +++ b/backend/auth/Dockerfile @@ -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 .. . diff --git a/backend/auth/app.py b/backend/auth/app.py index 0226eb2..0fbeb43 100644 --- a/backend/auth/app.py +++ b/backend/auth/app.py @@ -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) \ No newline at end of file + uvicorn.run(name, host="0.0.0.0", port=8000, reload=True, reload_dirs=["."]) \ No newline at end of file diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 4ef2b36..0241d4a 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -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