ci(docker): 优化Dockerfile使用国内镜像源

配置GOPROXY使用国内代理并替换Alpine镜像源为阿里云镜像,以加速构建过程
This commit is contained in:
zhouyonggao 2025-11-28 14:49:52 +08:00
parent 9c64d21bd4
commit 9df96375c3
1 changed files with 3 additions and 0 deletions

View File

@ -1,4 +1,6 @@
FROM golang:1.21-alpine AS build FROM golang:1.21-alpine AS build
ENV GOPROXY=https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
WORKDIR /app WORKDIR /app
RUN apk add --no-cache build-base RUN apk add --no-cache build-base
COPY server/ ./server/ COPY server/ ./server/
@ -7,6 +9,7 @@ WORKDIR /app/server
RUN go build -o /app/bin/marketing-data-server ./cmd/server RUN go build -o /app/bin/marketing-data-server ./cmd/server
FROM alpine:3.19 FROM alpine:3.19
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
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