build(docker): 添加 BASE_REGISTRY 参数以支持自定义基础镜像仓库
允许通过 BASE_REGISTRY 参数指定基础镜像仓库地址,提高部署灵活性
This commit is contained in:
parent
3b1fcb37d7
commit
7aa2a95fac
|
|
@ -1,4 +1,5 @@
|
||||||
FROM golang:1.21-alpine AS build
|
ARG BASE_REGISTRY=docker.io
|
||||||
|
FROM ${BASE_REGISTRY}/library/golang:1.21-alpine AS build
|
||||||
ARG ALPINE_MIRROR=mirrors.aliyun.com
|
ARG ALPINE_MIRROR=mirrors.aliyun.com
|
||||||
RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true
|
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
|
||||||
|
|
@ -10,7 +11,8 @@ COPY web/ ./web/
|
||||||
WORKDIR /app/server
|
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
|
ARG BASE_REGISTRY=docker.io
|
||||||
|
FROM ${BASE_REGISTRY}/library/alpine:3.19
|
||||||
ARG ALPINE_MIRROR=mirrors.aliyun.com
|
ARG ALPINE_MIRROR=mirrors.aliyun.com
|
||||||
RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true
|
RUN sed -i "s/dl-cdn.alpinelinux.org/${ALPINE_MIRROR}/g" /etc/apk/repositories || true
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ if docker image inspect "$IMAGE:$TAG" >/dev/null 2>&1; then
|
||||||
--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}" \
|
--build-arg ALPINE_MIRROR="${ALPINE_MIRROR:-mirrors.aliyun.com}" \
|
||||||
|
--build-arg BASE_REGISTRY="${BASE_REGISTRY:-docker.io}" \
|
||||||
--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"
|
||||||
|
|
@ -19,6 +20,7 @@ else
|
||||||
--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}" \
|
--build-arg ALPINE_MIRROR="${ALPINE_MIRROR:-mirrors.aliyun.com}" \
|
||||||
|
--build-arg BASE_REGISTRY="${BASE_REGISTRY:-docker.io}" \
|
||||||
-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