I have setup for my django project using nginx and uwsgi, similar to what is described here
I am now trying to use docker / docker compose to maintain it.
For the container with the django application, everything seems to be working fine when I use docker build, but when I use docker compose, the files do not seem to be updated properly.
The Dockerfile is:
FROM python:3.10-alpine
# Install Imagemagick package
# gcc and more are required to build the uswgi wheel
RUN apk add imagemagick imagemagick-dev imagemagick-pdf gcc python3-dev build-base linux-headers pcre-dev curl
# set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt /
RUN pip install -r requirements.txt
COPY django_app/ /app
COPY uwsgi.ini /
WORKDIR /app
RUN python ./manage.py migrate
RUN python ./manage.py collectstatic --noinput
docker-compoose.yml:
services:
redis:
image: redis:7-alpine
celery_worker:
build:
context: .
dockerfile: ./Dockerfile
image: celery
command: celery -A bg_upgrades worker -l info
env_file:
- ./docker_env
depends_on:
- redis
uwsgi:
build:
context: .
dockerfile: ./Dockerfile
image: uwsgi
env_file:
- ./docker_env
command: uwsgi --ini /uwsgi.ini
volumes:
- django_app:/app/
- socket:/sock/
depends_on:
- redis
nginx:
build:
context: ./nginx
dockerfile: ./Dockerfile
volumes:
- django_app:/app/
- socket:/sock/
depends_on:
- redis
- uwsgi
- celery_worker
ports:
- 80:80
volumes:
django_app:
socket:
Looking at other answers, here are a few things I've tried:
docker compose up -d --build --force-recreatedocker compose build --no-cache- Deleting all containers and images in the Docker UI
- Changing the names of the images in the
docker-compose.ymlfile - Adding a command
RUN rm -Rf /app/*before theCOPYin the Dockerfile docker compose downbefore restarting
Specifically, the file I am changing (and I don't see the changes reflected int he container) is at django_app/my_app/template/pattern_form.html.j2
Again, when I use docker build -t my_app:0.1 ., the file is updated properly (no change to the Dockerfile).
django_app:/app/. That will cause the image/app/directory to be copied to the volume when the volume is first created and then never updated again. So that might cause the issue you're having, if the file in question lives in that directory. See this for more info.