django live reload doesnt work with 2nd docker-compose file

  django, docker, docker-compose

I want to create 2 environments. Test and the standard dev environment. I need to run the django test server within test environment and the regular server, manage.py runserver on the other. The main dev environemnt will use the docker-compse.yml and the test environment will use test.yml. When I run docker-compose up, live-reload works normally. When i run docker-compose -f test.yml up, the test server runs but docker does not do live reloads. I add the same services to both files to shorten the CLI syntax.

docker-compose.yml

version: "3.9"

services:
    web:
        build: 
          dockerfile: ./compose/django/Dockerfile
          context: .
        container_name: main_app_django
        env_file: 
          - ./.local/.env
        command: compose/django/start.sh
        volumes:
          - .:/code
        ports:
          -  "8000:8000"
    
    redis:
      container_name: main_app_redis
      image: "redis:alpine"
      command: redis-server
      ports:
        - "6379:6379"
    

    celeryworker:
      build: 
        dockerfile: ./compose/celery/Dockerfile
        context: .
      container_name: main_app_celery
      command: celery -A app worker -l INFO
      env_file: 
        - ./.local/.env
      volumes:
        - .:/code 
      depends_on:
        - redis   

test.yml

version: "3.9"

services:
    web:
      build: 
        dockerfile: ./compose/django/Dockerfile
        context: .
      container_name: test_main_app_django
      env_file: 
        - ./.local/.env
      command: > 
        sh -c "python manage.py makemigrations &&
          python manage.py migrate && python manage.py testserver cypress/fixtures/user.json cypress/fixtures/tracks.json --addrport 0.0.0.0:8000"
      volumes:
        - .:/code
      ports:
        -  "8000:8000"
    
    redis:
      container_name: test_main_app_redis
      image: "redis:alpine"
      command: redis-server
      ports:
        - "6379:6379"
    
    celeryworker:
      build:
        dockerfile: ./compose/celery/Dockerfile
        context: .
      container_name: test_main_app_celery
      command: celery -A appworker -l INFO
      env_file: 
        - ./.local/.env
      volumes:
        - .:/code
      depends_on:
        - redis


Source: Docker Questions

LEAVE A COMMENT