From b6e83397a569ddc7b221e9f68dd11241c44f88c1 Mon Sep 17 00:00:00 2001
From: rt00492 <rt00492@surrey.ac.uk>
Date: Fri, 29 Apr 2022 16:48:55 +0100
Subject: [PATCH] Adding redis and sidekiq containers to facilitate asynchronus
 mailing

---
 app/controllers/home_controller.rb |  2 +-
 docker-compose.yaml                | 26 ++++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index af44bc3..ba25640 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -31,7 +31,7 @@ class HomeController < ApplicationController
     end
 
     def reminder_email_test
-        email_request = [session[:user_id], "2"]
+        email_request = [session[:user_id]]
         email = get_emails(email_request)
         if email == nil
         else
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 5239d73..0f7ebce 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -23,7 +23,21 @@ services:
 
         ports:
             - "3307:3307"
-    
+
+    redis:
+        image: redis:latest
+        restart: always
+        ports:
+        - '6379:6379'
+        command: redis-server --save 20 1 --loglevel warning
+        volumes: 
+        - redis:/data
+    sidekiq:
+        depends_on:
+        - 'redis'
+        command: sidekiq -C config/sidekiq.yml
+        image: driftydirt/group24mailer:0.0.5
+
     
     primary:
         build: .
@@ -45,6 +59,14 @@ services:
         links:
             - db_auth
     mailer:
-        image: driftydirt/group24mailer:0.0.3
+        image: driftydirt/group24mailer:0.0.5
         ports: 
             - "3002:3000"
+        environment: 
+            REDIS_HOST: redis
+            REDIS_PORT: 6379
+        links:
+            - redis
+volumes:
+    redis: 
+        driver: local
\ No newline at end of file
-- 
GitLab