diff --git a/Dockerfile b/Dockerfile index 59c5898..ca7e8a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,20 @@ FROM sutty/monit:latest MAINTAINER "f " + +RUN apk add --no-cache redis + +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 +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 new file mode 100644 index 0000000..a2a8fd1 --- /dev/null +++ b/monit.conf @@ -0,0 +1,4 @@ +check process redis with pidfile /run/redis/redis.pid + 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