I have a Django project that I am using with memcached and Docker. When I use sudo docker-compose up
in development I'd like the entire cache to be cleared. Rather than disabling caching wholesale while in development mode, is there a way to run cache.clear()
as noted in this question on each re-run of sudo docker-compose up
?
I am not sure whether this should go in:
docker-entrypoint.sh
Dockerfile
docker-compose.yml
- Somewhere else?
docker-compose.yml:
version: "3"
services:
redis:
image: "redis:alpine"
command: "redis-server --requirepass ${REDISPASS} --bind 0.0.0.0"
ports:
- '6379:6379'
memcached:
image: "memcached:latest"
ports:
- '11211:11211'
nginx:
image: nginx:latest
volumes:
- ./configuration/nginx/conf.d/:/etc/nginx/conf.d
- ./configuration/nginx/realtime:/etc/nginx/realtime
- ./static_cdn/static_root/static:/static
ports:
- 80:80
- 443:443
depends_on:
- app_main
- app_async_app1
- app_async_app2
app_main:
command: "djangoAppName.settings.prod ${SECRET_KEY} 1 ${DB_PASS} ${REDISPASS}"
image: "django_image_name"
ports:
- 0003:0003
volumes:
- ./static_cdn/static_root/:/static_cdn/
depends_on:
- redis
- memcached
app_async_app2:
command: "djangoAppName.settings.prod ${SECRET_KEY} 2 ${DB_PASS} ${REDISPASS}"
image: "django_image_name"
ports:
- 0002:0002
depends_on:
- redis
- memcached
- app_main
app_async_app1:
command: "djangoAppName.settings.prod ${SECRET_KEY} 3 ${DB_PASS} ${REDISPASS}"
image: "django_image_name"
depends_on:
- redis
- memcached
- app_main
ports:
- 0001:0001
react:
command: "npm run"
image: "django_image_name"
volumes:
- ./static_cdn/static_root/:/static_cdn/
depends_on:
- memcached
- app_main