Work on dockerfiles

- Moved builds around to put that should change most last. This allows
  docker to make best use of the cache.
- Added optimization level 2 to profiling and vanilla builds.