From 3d0af38c8c4f0ae283f7d599e1ae37ca5bc08674 Mon Sep 17 00:00:00 2001 From: TJWater CI Date: Tue, 11 Aug 2026 10:10:37 +0800 Subject: [PATCH] fix(container): keep runtime files out of CI image --- .dockerignore | 21 +++++++++++++++++++++ Dockerfile | 9 ++++----- 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8c48100 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +.git +.github +.gitea +__pycache__/ +.pytest_cache/ +.mypy_cache/ +.venv/ +venv/ +build/ +dist/ +package/ +.env +.env.* +db_inp/ +inp/ +temp/ +data/ +logs/ +coverage/ +*.pyc +*.dump diff --git a/Dockerfile b/Dockerfile index e2e530d..b94736e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,11 @@ RUN conda install -y -c conda-forge python=3.12 pymetis && \ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -# 将代码放入子目录 'app',将数据放入子目录 'db_inp' -# 这样临时文件默认会生成在 /app 下,而代码在 /app/app 下,实现了分离 +# 本地数据目录和环境变量在运行时通过 Compose 挂载或注入, +# 不应进入镜像构建上下文。 +RUN mkdir -p /app/db_inp /app/inp /app/data /app/temp + COPY app ./app -COPY db_inp ./db_inp -COPY temp ./temp -COPY .env . # 设置 PYTHONPATH 以便 uvicorn 找到 app 模块 ENV PYTHONPATH=/app