task-service (the rest service used to manage the jobs)
cdintotask_management_projectand run:
docker build -t django_service .
job_consumer (the rabbitmq consumer of the worker queue)
cdintotask_executorand run:
docker build -t job_consumer .
- create a network that will be used by the containers
docker network create --driver bridge custom
- start a
rabbitmqbroker
docker run --rm -it --hostname my-rabbit -p 15672:15672 -p 5672:5672 --network custom --name rabbit rabbitmq:3-management
- start a
task_executor(job_consumerimage)
docker run --rm -it --network custom job_consumer job_queue -rhs rabbit -hs task-service
- start the
task-service(django_taskimage)
docker run --rm -it --network custom --name task-service -p 8000:8000 -e docker_rabbit_host='rabbit' django_service
It's possible to take advantage of the browsable API
- create a new job or list existing ones:
http://127.0.0.1/api/jobs - get the details of a specific job or update some information:
http://127.0.0.1/api/jobs/<int:pk>
- make sure you have a rabbitmq broker running following point
1of the section "How to run the system in docker" - start a
task_executor(job_consumerimage) with a timeout of 2 seconds
docker run --rm -it --network custom job_consumer job_queue -rhs rabbit -hs task-service -to 2
- run the tests with
docker run --rm -it --network custom --name task-service --entrypoint python -p 8000:8000 -e docker_rabbit_host='rabbit' django_service -m pytest --liveserver task-service:8000