Refactored Dockerfile to make better use of cache