My Dockerfile is something like
FROM my/base
ADD . /srv
RUN pip install -r requirements.txt
RUN python setup.py install
ENTRYPOINT ["run_server"]
I found that a better way is to just add the Python site-packages directory as a volume.
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
- /usr/local/lib/python2.7/site-packages/
This way I can just pip install new libraries without having to do a full rebuild.
EDIT: Disregard this answer, jkukul's answer above worked for me. My intent was to cache the site-packages folder. That would have looked something more like:
volumes:
- .:/code
- ./cached-packages:/usr/local/lib/python2.7/site-packages/
Caching the download folder is alot cleaner though. That also caches the wheels, so it properly achieves the task.