git config --global url.git@HOSTNAME:.insteadOf https://HOSTNAME/- We don't need this dance in our Dockerfiles / build scripts / dev machines anymore. We have a baked GOPROXY / GONOSUMDB in our build image and developers configure the same proxy (via `go env -w`) locally.
- We pull all packages over the proxy, so builds are faster / use less bandwidth / still mostly work when GitHub goes down.
- SCAs get more difficult; the credentials the proxy has are more limited than any individual developer's GitLab tokens / credentials, and owning the proxy is going to be harder than a single developer's laptop.
machine <your GitLab domain> (e.g. gitlab.com) login <your GitLab id> password <your GitLab personal access token>
For the access token, you can also leverage Gitlab‘s CI Job Token.
What we do is an „echo $(netrc contents with $CI_JOB_TOKEN) > ~/.netrc“ in the pre-script in CI.
(https://stackoverflow.com/a/61257782 and https://docs.gitlab.com/ee/security/token_overview.html)
Don't know how that'll work out for a larger project but it works well enough in this small API I wrote.
But for other stuff (namely private npm packages), (relatively) modern versions of Docker support build-time-only secrets: https://docs.docker.com/develop/develop-images/build_enhance.... Pass the secret as part of the docker build command and then access it inside RUN --mount=... stages.