Installing dependencies but not app
See original GitHub issueMy current setup uses a requirements.txt which lists all my dependencies (and transitive dependencies), which I basically generate from pip-tools. To deploy my app, I do pip install -r requirements.txt
then pip install -e .
, to install the dependencies and the app, respectively.
What is great with this system is that it works correctly with Docker, caching the dependencies and keeping my builds very fast:
# This part will be cached, only reinstalling if I change the requirements
ADD requirements.txt ./
RUN pip install -r requirements.txt
# This part runs every time I change any of the app's code, but is fast because dependencies are installed
ADD setup.py app ./
RUN pip install -e .
I am not sure how to get this working with pipenv. If I install -e ./
, my app appears in Pipfile
, and there’s no way for me to install only the dependencies. If I don’t put my app in Pipfile, I need to copy all the dependencies from setup.py
to Pipfile
.
That makes the build for anyone using Docker hundreds of time slower, and is a huge barrier to Docker users moving to pipenv.
Expected result
Being able to use Pipfile
in my Docker build.
Actual result
Build is made very slow by the fact I can’t cache installation of the dependencies.
Steps to replicate
This fails because .
is not copied yet (it might even try to grab the app from Git):
ADD Pipfile Pipfile.lock ./
RUN pipenv install
I am not sure what’s a good fix for this, or if it’s high profile enough for pipenv devs to address. A way to install dependencies but not the app would solve this. A way to have Pipfile.lock
list the dependencies from setup.py
without having it list the app would be another way.
Anyone else using pipenv to build applications deployed via Docker?
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (15 by maintainers)
Top GitHub Comments
@remram44 how is this a terrible solution? Lock the dependency graph locally. Then remove your own package from the lockfile. Then copy your lockfile.
I can’t follow any aspect of your use case that would make this not work for you. Can you provide some output demonstrating exactly what you’re trying to do and why this doesn’t accomplish that?
Maybe I’m not understanding something, but why can’t you do
pipenv install -e .
ahead of time (i.e. so that everything’s tracked inPipfile.lock
), and then have your Dockerfile as something like:That way Docker caching still works, so long as you don’t change your deps.