From c64fa87e055c7a691b484defaef4427c535cde6d Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 29 Mar 2026 23:36:53 +0800 Subject: [PATCH] refactor: consolidate docker-compose service configurations using a shared base anchor --- Dockerfile | 4 +++- docker-compose.yml | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 50c474ca..0386f298 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ WORKDIR /app # 设置环境变量 ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_ROOT_USER_ACTION=ignore \ TZ=UTC # 安装系统依赖 (如果有必要的包可以取消注释) @@ -15,7 +17,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \ COPY requirements.txt . # 安装 Python 依赖 -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir --prefer-binary -r requirements.txt # 复制项目代码 COPY . . diff --git a/docker-compose.yml b/docker-compose.yml index bbda1c04..f1a94aca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,14 @@ +x-polyweather-base: &polyweather-base + build: . + image: polyweather-app:latest + env_file: + - .env + services: polyweather: - build: . + <<: *polyweather-base container_name: polyweather_bot restart: unless-stopped - env_file: - - .env volumes: # Persist runtime data outside git workspace. # Host path defaults to /var/lib/polyweather and can be overridden in .env. @@ -17,12 +21,10 @@ services: user: "${UID:-1000}:${GID:-1000}" polyweather_web: - build: . + <<: *polyweather-base container_name: polyweather_web restart: unless-stopped command: python web/app.py - env_file: - - .env volumes: # Web service shares the same runtime data directory as bot/state tasks. - ${POLYWEATHER_RUNTIME_DATA_DIR:-/var/lib/polyweather}:/var/lib/polyweather