Inject current git commit into docker container

Hello docker users,

I would like to inject current git commit hash into my GO binary during a build process. Something like this:

go build -ldflags "-X main.githash `git rev-parse HEAD`" service.go

How can i do that if i build my container on the docker hub?

Thanks,
-Andrey