From 675c1a9b12e263e50b7335b5fbedde22c06ad044 Mon Sep 17 00:00:00 2001 From: chenjiale Date: Thu, 4 Dec 2025 10:05:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20=E6=9B=B4=E6=96=B0=20Docker?= =?UTF-8?q?file=20=E5=92=8C=20Drone=20=E9=85=8D=E7=BD=AE=E4=BB=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E5=92=8C=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 +++- Dockerfile | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5c50b2c..6c40530 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,8 +30,10 @@ steps: commands: - docker stop alert-python || true - docker rm alert-python || true + # 确保宿主机存在可挂载的配置目录,并同步当前配置 + - docker run --rm -v /opt/alert/model-lab:/opt/alert/model-lab -v $(pwd)/config.py:/tmp/config.py alpine sh -c "mkdir -p /opt/alert/model-lab && cp /tmp/config.py /opt/alert/model-lab/config.py" # 启动 Python 服务容器,假设服务监听 8082 端口 - - docker run -d --restart always --name alert-python --network alert-net -p 8082:8082 alert-python:latest + - docker run -d --restart always --name alert-python --network alert-net -p 8082:8082 -v /opt/alert/model-lab:/opt/alert/model-lab -v /opt/alert/model-lab/config.py:/app/config.py alert-python:latest volumes: - name: dockersock diff --git a/Dockerfile b/Dockerfile index 09e0c41..be5e23d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,8 @@ RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua COPY . . -CMD ["python", "app.py"] \ No newline at end of file +# 预置配置文件到宿主可挂载的位置,便于后续覆盖 +RUN mkdir -p /opt/alert/model-lab \ + && cp /app/config.py /opt/alert/model-lab/config.py + +CMD ["python", "app.py"] -- 2.30.2