question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to deploy django-q with docker?

See original GitHub issue

Assume this simple docker-compose file

version: "3.9"
   
services:  
  redis:
    image: redis:alpine
    ports:
      - 6379:6379

  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - redis

How can i add django-q process to handle all requests from web container? I could probably build same image with different command such as python manage.py qcluster but I dont think this solution si elegant. Could you suggest some approach how to do that?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mhassan91commented, Feb 24, 2021

You need to run 2 docker containers. One for application server and one for django-q service. Your dockercompose file will look like this.

version: "3.9"
   
services:  
  redis:
    image: redis:alpine
    ports:
      - 6379:6379

  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - redis
  django-q:
    build: .
    command: python manage.py qcluster
    volumes:
      - .:/code
    depends_on:
      - redis
2reactions
FakieKickflipcommented, May 18, 2021

I have a question to this topic:

How can I serve environment variables (with os.environ[]) from a file to the settings.py with docker? It is working for my app but Django Q does not take those values and gave me errors like:

djangoq_1 | raise ImproperlyConfigured(“The SECRET_KEY setting must not be empty.”) djangoq_1 | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

djangoq_1 | ALLOWED_HOSTS = os.environ.get(“DJANGO_ALLOWED_HOSTS”).split(" ") djangoq_1 | AttributeError: ‘NoneType’ object has no attribute ‘split’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dockerizing a Python Django Web Application - Semaphore CI
Dockerizing a Python Django Web Application ; Click on Edit Workflow. Click on + Add Block. Set the name of the block to...
Read more >
Django samples - Docker Documentation
Compose and Django, This quick-start guide demonstrates how to use Docker Compose to set up and run a simple Django/PostgreSQL app.
Read more >
Dockerizing Django with Postgres, Gunicorn, and Nginx
This tutorial details how to configure Django to run on Docker along with Postgres, Nginx, and Gunicorn.
Read more >
Deploying Django with Docker Compose - YouTube
How to deploy a Django app to an EC2 instance using Docker Compose.Find the blog post for this tutorial here: ...
Read more >
How to Deploy a Django Application with Docker - DZone
Create Docker file · FROM - initializes a new build stage and sets the Base Image for subsequent instructions. · RUN - runs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found