Establish pip cache for docker containers
The containers aren't sharing the normal pip cache of `/home/docs/.cache/pip`, which also effects the wheel cache. We should explicitly specify a project-local pip cache dir to use, so that package install time can be reduced.

Raised in #1767 

diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py
index c7584e92c..3c8cf4dfb 100644
--- a/readthedocs/projects/models.py
+++ b/readthedocs/projects/models.py
@@ -412,6 +412,11 @@ class Project(models.Model):
     def venv_path(self, version=LATEST):
         return os.path.join(self.doc_path, 'envs', version)
 
+    @property
+    def pip_cache_path(self):
+        """Path to pip cache"""
+        return os.path.join(self.doc_path, '.cache', 'pip')
+
     #
     # Paths for symlinks in project doc_path.
     #
diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py
index d92576824..6146c1809 100644
--- a/readthedocs/projects/tasks.py
+++ b/readthedocs/projects/tasks.py
@@ -261,6 +261,8 @@ class UpdateDocsTask(Task):
             'install',
             '--use-wheel',
             '-U',
+            '--cache-dir',
+            self.project.pip_cache_path,
         ]
         if self.project.use_system_packages:
             # Other code expects sphinx-build to be installed inside the
@@ -294,6 +296,8 @@ class UpdateDocsTask(Task):
                 self.project.venv_bin(version=self.version.slug, filename='pip'),
                 'install',
                 '--exists-action=w',
+                '--cache-dir',
+                self.project.pip_cache_path,
                 '-r{0}'.format(requirements_file_path),
                 cwd=checkout_path,
                 bin_path=self.project.venv_bin(version=self.version.slug)
@@ -309,6 +313,8 @@ class UpdateDocsTask(Task):
                     self.project.venv_bin(version=self.version.slug, filename='pip'),
                     'install',
                     '--ignore-installed',
+                    '--cache-dir',
+                    self.project.pip_cache_path,
                     '.',
                     cwd=checkout_path,
                     bin_path=self.project.venv_bin(version=self.version.slug)
['readthedocs/projects/tasks.py', 'readthedocs/projects/models.py']