From a2332047665e50434ce15e93badf069827f10655 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 10 Sep 2019 20:23:34 -0300 Subject: [PATCH 1/3] redis --- Dockerfile | 15 +++++++++++++++ monit.conf | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 monit.conf diff --git a/Dockerfile b/Dockerfile index 59c5898..3669a88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,17 @@ FROM sutty/monit:latest MAINTAINER "f " + +RUN apk add --no-cache redis su-exec + +COPY ./monit.conf /etc/monit.d/redis.conf + +RUN sed -re "/^bind /d" -i /etc/redis.conf +RUN sed -re "/^protected-mode /d" -i /etc/redis.conf +RUN sed -re "/^logfile /d" -i /etc/redis.conf +RUN sed -re "s/^# (syslog-enabled).*/\1 yes/" -i /etc/redis.conf +RUN sed -re "s/^(appendonly).*/\1 yes/" -i /etc/redis.conf +RUN echo "pidfile /run/redis/redis.pid" >> /etc/redis.conf +RUN echo "daemonize yes" >> /etc/redis.conf + +EXPOSE 6379 +VOLUME "/var/lib/redis" diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..8779722 --- /dev/null +++ b/monit.conf @@ -0,0 +1,4 @@ +check process redis with pidfile /run/redis/redis.pid + start program = "/sbin/su-exec redis /usr/bin/redis-server /etc/redis.conf" + stop program = "/usr/bin/redis-cli shutdown" + if failed port 6379 protocol redis 3 times within 5 cycles then restart From f3620e7c490e3aaea6a6d1e538eca271f3b4ff73 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 17 Sep 2019 21:58:31 -0300 Subject: [PATCH 2/3] disable protected mode --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 3669a88..3dadfa0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ RUN sed -re "s/^# (syslog-enabled).*/\1 yes/" -i /etc/redis.conf RUN sed -re "s/^(appendonly).*/\1 yes/" -i /etc/redis.conf RUN echo "pidfile /run/redis/redis.pid" >> /etc/redis.conf RUN echo "daemonize yes" >> /etc/redis.conf +RUN echo "protected-mode no" >> /etc/redis.conf EXPOSE 6379 VOLUME "/var/lib/redis" From 4c5861f9b8391ca615a2d8e5e9d6e2a217716e0d Mon Sep 17 00:00:00 2001 From: f Date: Mon, 11 May 2020 12:09:13 -0300 Subject: [PATCH 3/3] eviction policy and maxmemory we're low on resources so 50MB is the most we can give it --- Dockerfile | 4 +++- monit.conf | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3dadfa0..ca7e8a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM sutty/monit:latest MAINTAINER "f " -RUN apk add --no-cache redis su-exec +RUN apk add --no-cache redis COPY ./monit.conf /etc/monit.d/redis.conf @@ -13,6 +13,8 @@ RUN sed -re "s/^(appendonly).*/\1 yes/" -i /etc/redis.conf RUN echo "pidfile /run/redis/redis.pid" >> /etc/redis.conf RUN echo "daemonize yes" >> /etc/redis.conf RUN echo "protected-mode no" >> /etc/redis.conf +RUN echo "maxmemory-policy allkeys-lfu" >> /etc/redis.conf +RUN echo "maxmemory 50mb" >> /etc/redis.conf EXPOSE 6379 VOLUME "/var/lib/redis" diff --git a/monit.conf b/monit.conf index 8779722..a2a8fd1 100644 --- a/monit.conf +++ b/monit.conf @@ -1,4 +1,4 @@ check process redis with pidfile /run/redis/redis.pid - start program = "/sbin/su-exec redis /usr/bin/redis-server /etc/redis.conf" + start program = "/usr/bin/redis-server /etc/redis.conf" as uid "redis" and gid "redis" stop program = "/usr/bin/redis-cli shutdown" if failed port 6379 protocol redis 3 times within 5 cycles then restart