From b599af5f0014d896b2d3365f942b74ebc2821397 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Fri, 7 Jul 2023 13:20:19 +0800 Subject: [PATCH] improve git token config --- Dockerfile | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 326c6a40f..fd459a9ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,22 +9,23 @@ FROM golang:1.20-alpine as builder RUN apk add --no-cache gcc musl-dev binutils-gold linux-headers git # Configure creds for gitea -ARG GITEA_TOKEN -RUN echo $GITEA_TOKEN > ~/.token -RUN git config --global credential.username _ # ignored, but prevents prompt -RUN git config --global credential.helper \ - '!f() { test "$1" = get && echo "password=$(cat $HOME/.token)"; }; f' +ARG GIT_VDBTO_TOKEN + +ENV GOPROXY="https://goproxy.cn,direct" # Get dependencies - will also be cached if we won't change go.mod/go.sum -COPY go.mod /go-ethereum/ -COPY go.sum /go-ethereum/ -RUN cd /go-ethereum && go mod download +WORKDIR /go-ethereum/ +COPY go.mod go.sum . +RUN [ -n "$GIT_VDBTO_TOKEN" ] && \ + git config --global url."https://$GIT_VDBTO_TOKEN@git.vdb.to/".insteadOf "https://git.vdb.to/" && \ + go mod download && \ + rm -f ~/.gitconfig -ADD . /go-ethereum -RUN cd /go-ethereum/wrapmain && go build --trimpath -o /go-ethereum/build/bin/geth . +COPY . . +RUN cd wrapmain && go build --trimpath -o /go-ethereum/build/bin/geth . # Pull Geth into a second stage deploy alpine container -FROM alpine:latest +FROM alpine:3.18 RUN apk add --no-cache ca-certificates COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/