Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tsh356 opened this issue Sep 3, 2019 · 4 comments
Closed

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

tsh356 opened this issue Sep 3, 2019 · 4 comments

Comments

@tsh356
Copy link

tsh356 commented Sep 3, 2019

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.

@ghost
Copy link

ghost commented Sep 4, 2019

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.

@omrihar
Copy link

omrihar commented Sep 6, 2019

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.

@tsh356 tsh356 closed this as completed Sep 7, 2019
@McSlow
Copy link

McSlow commented Oct 30, 2019

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

@tiangolo
Copy link
Owner

Thanks for the help here everyone! 👏 🙇

Thanks for reporting back and closing the issue 👍


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants