full-stack-fastapi-template icon indicating copy to clipboard operation
full-stack-fastapi-template copied to clipboard

[Question] How do you add python dependencies to the project?

Open tsh356 opened this issue 7 years ago • 4 comments

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.

tsh356 avatar Sep 03 '19 13:09 tsh356

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.

ghost avatar Sep 04 '19 13:09 ghost

What I'm doing is the following (not ideal, but what @tiangolo recommended doing):

  1. Add the requirements to backend.dockerfile as a line RUN pip install package (after most of the lines in the docker file so I can use the caching mechanism of docker).
  2. Optionally add the dependency to the tests.dockerfile file as well (if you need it for the testing).
  3. 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.

omrihar avatar Sep 06 '19 11:09 omrihar

There's a pipfile with all the dependencies, what is it used for at the moment?

McSlow avatar Oct 30 '19 20:10 McSlow

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...

tiangolo avatar Apr 10 '20 19:04 tiangolo