[Question] How do you add python dependencies to the project?
Should I add packages to the RUN command in the backend.dockerfile? Or add them to the Pipefile? Both? And what command actually updates the container? docker-compose up doesn't seem to be installing the new dependencies.
Docker-compose build would install the new dependencies. And what I'm doing is to pip install my the requirements.txt file via the RUN command in the backend.dockerfile.
What I'm doing is the following (not ideal, but what @tiangolo recommended doing):
- Add the requirements to
backend.dockerfileas a lineRUN pip install package(after most of the lines in the docker file so I can use the caching mechanism of docker). - Optionally add the dependency to the
tests.dockerfilefile as well (if you need it for the testing). - Add to the Pipfile so I get code completion from the editor when developing outside of the container.
To refresh the container I usually run docker-compose up -d --build backend - this just rebuilds the backend and ups it once it's done. I actually have a bunch of docker-compose commands in a Makefile so I can simply run make refresh-backend and don't forget it.
There's a pipfile with all the dependencies, what is it used for at the moment?
Thanks for the help here everyone! :clap: :bow:
Thanks for reporting back and closing the issue :+1:
I'm not really happy with the way packages are handled. The Pipfile is only for the local development environment. Using a Pipfile or requirements.txt doesn't play well with the Docker cache, so that's not ideal either. I still don't have a "favorite" solution for this...