diff --git a/Dockerfile b/Dockerfile index b84e53e..6914713 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ FROM golang:1.21-alpine AS build +ARG ALPINE_MIRROR=mirrors.aliyun.com +RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true ARG GOPROXY=https://goproxy.cn,direct ENV GOPROXY=$GOPROXY WORKDIR /app @@ -9,6 +11,8 @@ WORKDIR /app/server RUN go env -w GOPROXY=$GOPROXY && go build -o /app/bin/marketing-data-server ./cmd/server FROM alpine:3.19 +ARG ALPINE_MIRROR=mirrors.aliyun.com +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 COPY --from=build /app/web /app/web diff --git a/scripts/deploy_docker.sh b/scripts/deploy_docker.sh index f0b4d64..fde7363 100644 --- a/scripts/deploy_docker.sh +++ b/scripts/deploy_docker.sh @@ -11,12 +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}" \ --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}" \ -t "$IMAGE:$TAG" -f Dockerfile . fi mkdir -p log storage/export