Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cookiecutter-django local development with docker

I've never use docker for development on local machine so I have few questions that I didn't find in documentation.

  1. After setup I can't figure out how do I can install my packages via pip. I tried: docker-compose -f local.yml run --rm django pip install some-package. It installed package somewhere, but not in project. Do I need to build every time when I add new package?

  2. How to run django managment commands in another thread docker-compose -f local.yml run --rm django python manage.py mycommand stop runserver command that is not convenient

  3. Where do I see celery tasks log ? How to run: celery -A apps.taskapp worker -l info celery -A apps.taskapp beat -l INFO to see debug messages of my tasks

like image 216
Arti Avatar asked Dec 13 '22 17:12

Arti


1 Answers

I am assuming you started your project using the cookiecutter-django template.

  1. First time setup you run docker-compose -f local.yml build. This will install all the dependencies defined in local.txt. If you add any customized pip package to either local.txt or base.txt, you will have to re-build the docker image `docker-compose -f local.yml build.

  2. To run any commands in a docker container, you do: docker-compose -f local.yml run django [commands you would like to run]

Note: in the above command django is the name service defined in your local.yml

For example, to apply migrations in docker: docker-compose -f local.yml run django python manage.py migrate

  1. To start all services (django/postgres/celery/mailhog/etc) , just run: docker-compose -f local.yml up

You can inspect the logs of specific running docker container by: docker logs -f [name or id of container] which you can find out by: docker ps

like image 171
sfdye Avatar answered Dec 16 '22 07:12

sfdye