From 1595c5de2c46c195daf4c25cd5db51832035d71c Mon Sep 17 00:00:00 2001 From: Chris Ainsworth-Patrick Date: Fri, 18 Aug 2023 17:22:53 +0100 Subject: [PATCH] need to auth before go mod download --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1762d0f..57a5e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,13 @@ FROM golang:1.19-alpine AS build RUN apk --no-cache add git +ENV GOPRIVATE=github.com/docker +RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts +RUN --mount=type=secret,id=gitghatoken \ + (test -f /run/secrets/gitghatoken && \ + git config --global url."https://x-access-token:$(cat /run/secrets/gitghatoken)@github.com/docker".insteadOf "https://github.com/docker" || \ + git config --global url."git@github.com:docker/".insteadOf "https://github.com/docker/") + WORKDIR /app COPY go.mod ./ @@ -13,13 +20,6 @@ COPY main.go ./ COPY docker/ ./docker/ COPY babashka/ ./babashka/ -ENV GOPRIVATE=github.com/docker -RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts -RUN --mount=type=secret,id=gitghatoken \ - (test -f /run/secrets/gitghatoken && \ - git config --global url."https://x-access-token:$(cat /run/secrets/gitghatoken)@github.com/docker".insteadOf "https://github.com/docker" || \ - git config --global url."git@github.com:docker/".insteadOf "https://github.com/docker/") - RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o babashka-pod-docker FROM alpine:3.17