0

I'm working in a project generated by cookiecutter-django localy using docker, I wanted to add new packeges, what is the best aproche to perform this?

I'm actually copying the version of the package and pasting into the base requirements file and building the local.yaml contener again and it's seams to be rebuilding the entire containers in the project instead of building only the container that changes has been detected. So i don't if my aproche is the best, so please help me acheive this

  • WIthout any actual details, it will be hard to help you. Maybe show the commands you ran, some details of the console output, some relevant excerpts of your `docker-compose.yml` file or `Dockerfile`s, your project's file directory structure, the link to the cookiecutter template you used. Anything. Ideally you would provide a full [mre]. – sinoroc Jan 17 '23 at 09:10

1 Answers1

0

Given how you tagged the question, I assume you want to add a new Python package to a project that was generated using cookiecutter-django.

I think that the way you're doing it is correct. To be 100% clear, you need to:

  1. Edit the requirement file where you want it installed:
    • local.txt for local only
    • production.txt for production only
    • base.txt for both
  2. Rebuild your containers: docker-compose -f local.yml build
  3. Restart your containers: docker-compose -f local.yml up -d

The 2nd step may feel a bit heavy, as it would reinstall all the Python packages, not the just the new one, but AFAIU that's how Docker works.

Hope that helps!

Bruno A.
  • 1,765
  • 16
  • 17
  • You can also start with `docker compose -f local.yml up --build` to rebuild if necessary. Also, I would not detach (`-d`) when working locally because you won't see any output and can't stop the containers with `^C`. – dacx Jan 19 '23 at 09:44