How do you make a synced volume with Docker, Django and Gunicorn?

Google solutions does not help, I feel like the problem is in me using Gunicorn as local server. I just cant get my volume to sync and update with me changing local files, how do I do that? Force re-build volume ever ytime sounds like something highly inefficient Tried used Watchtower but had no luck as well

compose.yml

services:
  back:
    container_name: blog-django
    build: ./blog-master
    command:  gunicorn blog.wsgi:application --bind 0.0.0.0:8000
    expose:
    - 8000
    links:
      - db
    volumes:
      - .:/app
      - blog-django:/usr/src/app/
      - blog-static:/usr/src/app/static
    env_file: ./.env
    depends_on:
      db:
        condition: service_healthy
  nginx:
    container_name: blog-nginx
    build: ./nginx/
    ports:
      - "1337:80"
    volumes:
      - blog-static:/usr/src/app/static
    links:
      - back
    depends_on:
      - back 

  db:
    container_name: blog-db
    image: postgres:14
    restart: always
    expose:
      - "5432"
    environment:
      - POSTGRES_DB=docker
      - POSTGRES_USER=docker
      - POSTGRES_PASSWORD=docker
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data/
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U docker"]
      interval: 5s
      timeout: 5s
      retries: 5

  mailhog:
    container_name: mailhog
    image: mailhog/mailhog
    #logging:
    #  driver: 'none'  # disable saving logs
    expose:
      - 1025
    ports:
      - 1025:1025 # smtp server
      - 8025:8025 # web ui


volumes:
  blog-django:
  blog-static:
  pgdata:

Dockerfile

FROM python:3.9.6-alpine


WORKDIR /usr/src/app/
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev

RUN pip install --upgrade pip
RUN apk update \
    && apk add postgresql-dev gcc python3-dev musl-dev
    
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

Back to Top