ci(docker): 使用阿里云镜像源加速 alpine 包下载
在 Dockerfile 和部署脚本中添加 ALPINE_MIRROR 参数,默认使用阿里云镜像源替换 alpine 官方源,以加速包下载速度
This commit is contained in:
parent
27cdc9744f
commit
3b1fcb37d7
|
|
@ -1,4 +1,6 @@
|
||||||
FROM golang:1.21-alpine AS build
|
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
|
ARG GOPROXY=https://goproxy.cn,direct
|
||||||
ENV GOPROXY=$GOPROXY
|
ENV GOPROXY=$GOPROXY
|
||||||
WORKDIR /app
|
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
|
RUN go env -w GOPROXY=$GOPROXY && go build -o /app/bin/marketing-data-server ./cmd/server
|
||||||
|
|
||||||
FROM alpine:3.19
|
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
|
WORKDIR /app
|
||||||
COPY --from=build /app/bin/marketing-data-server /app/bin/marketing-data-server
|
COPY --from=build /app/bin/marketing-data-server /app/bin/marketing-data-server
|
||||||
COPY --from=build /app/web /app/web
|
COPY --from=build /app/web /app/web
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ if docker image inspect "$IMAGE:$TAG" >/dev/null 2>&1; then
|
||||||
DOCKER_BUILDKIT=1 docker build \
|
DOCKER_BUILDKIT=1 docker build \
|
||||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||||
--build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \
|
--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 .
|
--cache-from "$IMAGE:$TAG" -t "$IMAGE:$TAG" -f Dockerfile .
|
||||||
else
|
else
|
||||||
echo "镜像不存在,开始构建: $IMAGE:$TAG"
|
echo "镜像不存在,开始构建: $IMAGE:$TAG"
|
||||||
DOCKER_BUILDKIT=1 docker build \
|
DOCKER_BUILDKIT=1 docker build \
|
||||||
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
--build-arg BUILDKIT_INLINE_CACHE=1 \
|
||||||
--build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \
|
--build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \
|
||||||
|
--build-arg ALPINE_MIRROR="${ALPINE_MIRROR:-mirrors.aliyun.com}" \
|
||||||
-t "$IMAGE:$TAG" -f Dockerfile .
|
-t "$IMAGE:$TAG" -f Dockerfile .
|
||||||
fi
|
fi
|
||||||
mkdir -p log storage/export
|
mkdir -p log storage/export
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue