From f7e79269f5402ea52201655efc9233f50422d8f6 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 1 Jun 2026 12:39:35 +0800 Subject: [PATCH] ci(build): add aliyun mirror switch and fix redis command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 为Dockerfile添加USE_ALIYUN_MIRROR构建参数,支持切换使用阿里云镜像源 2. 移除docker-compose.yml中redis的动态密码参数配置 3. 在CI工作流中默认关闭阿里云镜像源 --- .github/workflows/ci.yml | 1 + Dockerfile | 6 ++++++ docker-compose.yml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c90d705..e39345c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -274,6 +274,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: USE_ALIYUN_MIRROR=false - name: 添加架构标签 if: startsWith(github.ref, 'refs/tags/') diff --git a/Dockerfile b/Dockerfile index f73b9f7..cb287af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,12 @@ # 构建阶段 FROM python:3.12-slim AS builder +ARG USE_ALIYUN_MIRROR=false +RUN if [ "$USE_ALIYUN_MIRROR" = "true" ]; then \ + sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \ + sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list 2>/dev/null || true; \ +fi + WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/docker-compose.yml b/docker-compose.yml index 49c22eb..2b74374 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: network_mode: host volumes: - redis_data:/data - command: redis-server --appendonly yes ${REDIS_PASSWORD:+--requirepass ${REDIS_PASSWORD}} + command: redis-server --appendonly yes healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s