diff --git a/.env.sample b/.env.sample index e811512..f9a1c34 100644 --- a/.env.sample +++ b/.env.sample @@ -6,6 +6,9 @@ MYSQL_PASSWORD=clrt_pwd MYSQL_HOST=clrt_mysql_host MYSQL_PORT=3306 +# Redis settings +REDIS_LOCATION=redis://clrt_redis_host:6379 + #Django settings SECRET_KEY='your-django-key' DJANGO_DEBUG=True diff --git a/backend/settings.py b/backend/settings.py index c545f65..af809e2 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -157,16 +157,13 @@ } } -# This is needed to allow the LTI tool to work with the Django cache when running on multiple workers CACHES = { "default": { - "BACKEND": "django_mysql.cache.MySQLCache", - "LOCATION": "django_clrt_cache", - "KEY_PREFIX": "clrt", + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": config('REDIS_LOCATION', "redis://clrt_redis_host:6379") } } - # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators @@ -214,4 +211,4 @@ CSP_STYLE_SRC = ["'self'", "https:", "'unsafe-inline'"] CSP_FRAME_ANCESTORS = ["'self'"] + [url.strip() for url in config('CSP_FRAME_ANCESTORS', 'canvas-test.it.umich.edu').split(',')] CSP_IMG_SRC = ["'self'", "data:"] -CSP_FONT_SRC = ["'self'"] \ No newline at end of file +CSP_FONT_SRC = ["'self'"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 1773862..0dbb4b3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,9 +12,20 @@ services: ports: - "4306:3306" volumes: - - ./.data/mysql:/var/lib/mysql + - ./.data/mysql:/var/lib/mysql container_name: clrt_mysql_host + redis: + image: redis:7 + command: redis-server --stop-writes-on-bgsave-error no --save "" + # This is to simulate an Openshift container with no write permission except to /tmp + read_only: true + tmpfs: + - /tmp + volumes: + - clrt-redis-data:/data:ro + container_name: clrt_redis_host + web: build: context: . @@ -30,4 +41,7 @@ services: - mysql env_file: - .env - container_name: clrt_web \ No newline at end of file + container_name: clrt_web + +volumes: + clrt-redis-data: diff --git a/lti_redirect/migrations/0002_drop_mysql_cache.py b/lti_redirect/migrations/0002_drop_mysql_cache.py new file mode 100644 index 0000000..0149b4a --- /dev/null +++ b/lti_redirect/migrations/0002_drop_mysql_cache.py @@ -0,0 +1,13 @@ +from django.db import migrations + +class Migration(migrations.Migration): + + dependencies = [ + ('lti_redirect', '0001_mysql_cache'), # Ensure this is the correct dependency + ] + + operations = [ + migrations.RunSQL( + sql="DROP TABLE IF EXISTS django_clrt_cache;", + ), + ] diff --git a/requirements.txt b/requirements.txt index 8df9d9d..de3f02a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ django-mysql==4.14.0 gunicorn==22.0.0 whitenoise==6.7.0 debugpy==1.8.2 +redis==5.0.7