chore: 更新.gitignore并优化Docker构建配置

添加marketing-system-data-tool.tar到.gitignore
在Dockerfile和部署脚本中增加GOPROXY配置以加速构建
This commit is contained in:
zhouyonggao 2025-12-02 17:10:36 +08:00
parent 67c1b91bea
commit d245d3bce8
3 changed files with 7 additions and 2 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@ server/config.test.yaml
server/config.prod.yaml
server/config.yaml
server/bin/
scripts/*.tar
scripts/*.tar
marketing-system-data-tool.tar

View File

@ -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

View File

@ -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