Setup local Athens for proper go mod

There is a project called Athens for proxying all your go mod downloads.

How to use it locally.

1. Create the following files and directories:
a. /Users/d.bolgov/.ssh-athens/storage — empty directory to cache go modules
b. /Users/d.bolgov/.ssh-athens/.netrc — if you prefer using .netrc

machine github.com
    login [yourlogin]
    password [yourpassword]

c. /Users/d.bolgov/.ssh-athens/gitconfig/.gitconfig — if you want to substitue some urls.
I personally left it empty, but you can do something like that:

[url "ssh://git@github.com:[companyname]"]
	insteadOf = http://github.com/[companyname]

d. /Users/d.bolgov/.ssh-athens/ssh-keys should have a copy of your ~/.ssh directory

2. Run Athens in docker like that:

docker run -v "/Users/d.bolgov/.ssh-athens/storage:/var/lib/athens" -v "/Users/d.bolgov/.ssh-athens/.netrc:/root/.netrc" -v "/Users/d.bolgov/.ssh-athens/gitconfig/.gitconfig:/root/.gitconfig" -v "/Users/d.bolgov/.ssh-athens/ssh-keys:/root/.ssh" -e ATHENS_DISK_STORAGE_ROOT=/var/lib/athens -e ATHENS_STORAGE_TYPE=disk -e ATHENS_NETRC_PATH=/root/.netrc -e ATHENS_GONOSUM_PATTERNS="github.com/[companyname]/*" --name athens-proxy -p '3000:3000' --rm gomods/athens:latest

3. In the Dockerfile of your project (or you can do similar in your ~/.zshrc), for mac os:

ENV GOPROXY="http://docker.for.mac.host.internal:3000"

LEAVE A COMMENT