Check building on `hub.docker.com` or local machine, then execute corresponding code

Hi,

I am in China, I need create a docker image with custom apt-get source ,pip source and so on.? (Because of GFW in China, default source is usually unreachable or very very slow )

I write a Dockfile here https://github.com/eromoe/base/blob/master/Dockerfile

Local building is fine, but can not build on hub.docker.com for a long time, detail https://hub.docker.com/r/eromoe/base/builds/blen9qjpkxogo2bac5qq2nu/
Looks like some network error.

I only want to use one Dockerfile to support Local building and dockerhub host. So is there any way to check if building in hub.docker.com or local and execute corresponding code? Such as, when build in hub.docker.com, update source at last .