diff --git a/Dockerfile b/Dockerfile index b8a7b87..2593009 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,22 @@ RUN apk add --no-cache git ca-certificates tzdata # Copy go mod files COPY go.mod go.sum ./ -# Download dependencies -RUN go mod download +# Set Go environment variables and proxy +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux \ + GOARCH=amd64 \ + GOPROXY=https://goproxy.cn,https://goproxy.io,direct \ + GOSUMDB=sum.golang.google.cn + +# Download dependencies with retry mechanism +RUN go mod download || \ + (echo "Retrying with different proxy..." && \ + go env -w GOPROXY=https://goproxy.io,https://mirrors.aliyun.com/goproxy/,direct && \ + go mod download) || \ + (echo "Final retry with direct mode..." && \ + go env -w GOPROXY=direct && \ + go mod download) # Copy source code COPY . .