From a199129ada8296a912d5e3d2c7c3c20e3ca74a41 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 31 Oct 2025 09:28:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f0f57c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.11-slim + +# 设置 pip 全局使用国内源 +ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple/ +ENV PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8000 + +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file From d27a003bb0b0c62560ad66fc8f30c35042fe93a4 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 31 Oct 2025 09:29:36 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20docker-compose.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9a5e84e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + app: + build: . + ports: + - "8060:8000" + volumes: + - .:/app + environment: + - PYTHONUNBUFFERED=1 + # 开发模式:启用 --reload + command: uvicorn app:app --reload --host 0.0.0.0 --port 8000 + # 生产模式:注释上面 command,取消注释下面这行 + # command: uvicorn app:app --host 0.0.0.0 --port 8000 --workers 4 \ No newline at end of file From ae567a996a68e5cbd3238b703c904788b44ee77d Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 31 Oct 2025 09:43:56 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20docker-compose.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9a5e84e..26f9579 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,6 @@ services: environment: - PYTHONUNBUFFERED=1 # 开发模式:启用 --reload - command: uvicorn app:app --reload --host 0.0.0.0 --port 8000 + command: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 # 生产模式:注释上面 command,取消注释下面这行 - # command: uvicorn app:app --host 0.0.0.0 --port 8000 --workers 4 \ No newline at end of file + # command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4 \ No newline at end of file From 72f97350006d75f335c70315adeb42d5483ba403 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 31 Oct 2025 09:44:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4f0f57c..747db6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ COPY . . EXPOSE 8000 -CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file