Rearrange Dockerfile to improve caching and make most rebuilds superfast