Skip to content

Instantly share code, notes, and snippets.

@cedws
Last active February 25, 2024 23:25
Show Gist options
  • Save cedws/24a90913df631d271a59bbc1ff992de9 to your computer and use it in GitHub Desktop.
Save cedws/24a90913df631d271a59bbc1ff992de9 to your computer and use it in GitHub Desktop.
$ docker build --ssh default .
$ docker build --secret id=netrc,src=netrc --build-arg CI=1 .
FROM golang:latest
WORKDIR /build
COPY . .
ARG GITHUB_HOST_KEY_ED25519="AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"
ARG CI
ARG GIT_CONFIG_COUNT=${CI:+0}
ENV GIT_CONFIG_COUNT ${GIT_CONFIG_COUNT:-1}
ENV GIT_CONFIG_KEY_0 "url.ssh://[email protected]"
ENV GIT_CONFIG_VALUE_0 "https://github.com"
RUN mkdir ~/.ssh
COPY <<-EOF /root/.ssh/known_hosts
github.com ssh-ed25519 ${GITHUB_HOST_KEY_ED25519}
EOF
RUN --mount=type=secret,id=netrc,dst=/root/.netrc \
--mount=type=ssh \
go mod tidy
machine github.com
password ${PAT}
login oauth2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment