From 924ea7f7f8bf28b36454523555aa4ea6af4d8280 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Tue, 2 Dec 2025 16:44:38 +0800 Subject: [PATCH] =?UTF-8?q?build(docker):=20=E4=BF=AE=E6=94=B9=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E9=95=9C=E5=83=8F=E6=BA=90=E4=B8=BA=E5=8D=8E=E4=B8=BA?= =?UTF-8?q?=E4=BA=91=E9=95=9C=E5=83=8F=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将Dockerfile和部署脚本中的基础镜像源从docker.io和阿里云镜像改为华为云镜像仓库,以提高国内构建速度和稳定性 --- Dockerfile | 9 +++------ scripts/deploy_docker.sh | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7847f82..f5d5a37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -ARG BASE_REGISTRY=docker.io -FROM ${BASE_REGISTRY}/library/golang:1.21-alpine AS build -ARG ALPINE_MIRROR=mirrors.aliyun.com +ARG BASE_REGISTRY=repo.huaweicloud.com +FROM repo.huaweicloud.com/dockerhub/library/golang:1.21-alpine AS build RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true ARG GOPROXY=https://goproxy.cn,direct ENV GOPROXY=$GOPROXY @@ -11,9 +10,7 @@ COPY web/ ./web/ WORKDIR /app/server RUN go env -w GOPROXY=$GOPROXY && go build -o /app/bin/marketing-data-server ./cmd/server -ARG BASE_REGISTRY=docker.io -FROM ${BASE_REGISTRY}/library/alpine:3.19 -ARG ALPINE_MIRROR=mirrors.aliyun.com +FROM ${BASE_REGISTRY}/dockerhub/library/alpine:3.19 RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true WORKDIR /app COPY --from=build /app/bin/marketing-data-server /app/bin/marketing-data-server diff --git a/scripts/deploy_docker.sh b/scripts/deploy_docker.sh index 1e04079..d8dc693 100644 --- a/scripts/deploy_docker.sh +++ b/scripts/deploy_docker.sh @@ -11,16 +11,14 @@ if docker image inspect "$IMAGE:$TAG" >/dev/null 2>&1; then DOCKER_BUILDKIT=1 docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \ - --build-arg ALPINE_MIRROR="${ALPINE_MIRROR:-mirrors.aliyun.com}" \ - --build-arg BASE_REGISTRY="${BASE_REGISTRY:-docker.io}" \ + --build-arg BASE_REGISTRY="${BASE_REGISTRY:-repo.huaweicloud.com}" \ --cache-from "$IMAGE:$TAG" -t "$IMAGE:$TAG" -f Dockerfile . else echo "镜像不存在,开始构建: $IMAGE:$TAG" DOCKER_BUILDKIT=1 docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \ - --build-arg ALPINE_MIRROR="${ALPINE_MIRROR:-mirrors.aliyun.com}" \ - --build-arg BASE_REGISTRY="${BASE_REGISTRY:-docker.io}" \ + --build-arg BASE_REGISTRY="${BASE_REGISTRY:-repo.huaweicloud.com}" \ -t "$IMAGE:$TAG" -f Dockerfile . fi mkdir -p log storage/export