From 252a4015c4109fc27e88e5dddc8c7d97b2d08f4d Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 6 Jul 2023 14:52:36 -0500 Subject: [PATCH] 49: Use a Personal Access Token to access private modulees. --- Dockerfile | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9317deb..729975e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,23 +3,21 @@ 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' - -WORKDIR /plugeth-statediff/ +ARG gitea_access_token +ENV GITEA_ACCESS_TOKEN=$gitea_access_token # Get and cache deps -COPY go.mod . -COPY go.sum . -RUN go mod download +COPY go.mod /plugeth-statediff/ +COPY go.sum /plugeth-statediff/ +RUN if [ -n "$GITEA_ACCESS_TOKEN" ]; then git config --global url."https://$GITEA_ACCESS_TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"; fi && \ + cd /plugeth-statediff && \ + go mod download && \ + rm -f ~/.gitconfig -ADD . . -RUN go build --tags linkgeth --buildmode=plugin --trimpath -o statediff.so ./main +ADD . /plugeth-statediff +RUN cd /plugeth-statediff && \ + go build --tags linkgeth --buildmode=plugin --trimpath -o statediff.so ./main -FROM alpine:latest +FROM alpine:3.18 COPY --from=builder /plugeth-statediff/statediff.so /usr/local/lib/