chore(docker): 配置 Alpine 国内镜像源以提升构建速度
- 在 Dockerfile 中添加对 Alpine 国内镜像源(阿里云)的配置,优化包安装速度。 - 确保在构建和运行阶段均使用国内镜像源,以提高构建效率和稳定性。
This commit is contained in:
parent
ebcff4433b
commit
3da3d9186a
|
|
@ -4,6 +4,8 @@ ENV GO111MODULE=on
|
||||||
ENV GOPROXY=https://goproxy.cn,direct
|
ENV GOPROXY=https://goproxy.cn,direct
|
||||||
# 确保 PATH 包含 Go bin 目录,以便 protoc 能找到插件
|
# 确保 PATH 包含 Go bin 目录,以便 protoc 能找到插件
|
||||||
ENV PATH=$PATH:/go/bin
|
ENV PATH=$PATH:/go/bin
|
||||||
|
# 配置 Alpine 国内镜像源(阿里云)
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
# 安装构建所需的工具:git、protoc、make
|
# 安装构建所需的工具:git、protoc、make
|
||||||
RUN apk add --no-cache git protobuf make
|
RUN apk add --no-cache git protobuf make
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -60,6 +62,8 @@ RUN go build -ldflags="-w -s" -trimpath -o /out/server ./cmd/server/main.go && \
|
||||||
|
|
||||||
# 使用最小化的 alpine 镜像(包含时区支持,应用需要 loc=Local)
|
# 使用最小化的 alpine 镜像(包含时区支持,应用需要 loc=Local)
|
||||||
FROM alpine:3.19
|
FROM alpine:3.19
|
||||||
|
# 配置 Alpine 国内镜像源(阿里云)
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
# 安装运行时必需的包:时区和 CA 证书
|
# 安装运行时必需的包:时区和 CA 证书
|
||||||
RUN apk add --no-cache ca-certificates tzdata && \
|
RUN apk add --no-cache ca-certificates tzdata && \
|
||||||
mkdir -p /app/storage/export /app/log
|
mkdir -p /app/storage/export /app/log
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue