diff --git a/.gitignore b/.gitignore index 11ea277..e18147e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ server/config.test.yaml server/config.prod.yaml server/config.yaml server/bin/ -scripts/*.tar \ No newline at end of file +scripts/*.tar +marketing-system-data-tool.tar diff --git a/Dockerfile b/Dockerfile index d49ffac..c1df48c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,14 @@ ARG TARGETOS=linux ARG TARGETARCH=amd64 ARG TARGETVARIANT="" ENV CGO_ENABLED=0 +ARG GOPROXY=https://goproxy.cn,direct +ENV GOPROXY=$GOPROXY WORKDIR /app RUN apk add --no-cache git COPY server/ ./server/ COPY web/ ./web/ WORKDIR /app/server -RUN GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$(echo $TARGETVARIANT | sed 's/^v//') go build -o /app/bin/marketing-data-server ./cmd/server +RUN go env -w GOPROXY=$GOPROXY && GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$(echo $TARGETVARIANT | sed 's/^v//') go build -o /app/bin/marketing-data-server ./cmd/server FROM alpine:3.19 WORKDIR /app diff --git a/scripts/deploy_docker.sh b/scripts/deploy_docker.sh index 7187162..f0b4d64 100644 --- a/scripts/deploy_docker.sh +++ b/scripts/deploy_docker.sh @@ -10,11 +10,13 @@ if docker image inspect "$IMAGE:$TAG" >/dev/null 2>&1; then echo "使用已有镜像作为缓存: $IMAGE:$TAG" DOCKER_BUILDKIT=1 docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" \ --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}" \ -t "$IMAGE:$TAG" -f Dockerfile . fi mkdir -p log storage/export