Skip to content

Commit 66539ac

Browse files
committed
close #2
1 parent 87e96eb commit 66539ac

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv C7917B12 && \
1111
# Add scripts
1212
ADD run.sh /run.sh
1313
ADD set_redis_password.sh /set_redis_password.sh
14-
ADD set_redis_mode.sh /set_redis_mode.sh
15-
RUN chmod 755 /*.sh
14+
RUN chmod +x /*.sh
15+
16+
# SET environment variables
17+
ENV REDIS_MODE **None**
18+
ENV REDIS_TIMEOUT 0
1619

1720
EXPOSE 6379
1821
CMD ["/run.sh"]

run.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
#!/bin/bash
2-
if [ ! -f /.redis_mode_set ]; then
3-
/set_redis_mode.sh
2+
if [ "${REDIS_MODE}" == "**None**" ]; then
3+
unset REDIS_MODE
44
fi
5+
6+
if [ ! -f /.redis_configured ]; then
7+
if [ "$REDIS_MODE" == "LRU" ]; then
8+
echo "=> Configuring redis as a LRU cache"
9+
MAXMEMORY=${REDIS_MAXMEMORY:-"256mb"}
10+
touch /etc/redis/redis_default.conf
11+
echo "maxmemory $MAXMEMORY" >> /etc/redis/redis_default.conf
12+
echo "maxmemory-policy allkeys-lru" >> /etc/redis/redis_default.conf
13+
else
14+
echo "=> Unknown $REDIS_MODE mode - ignoring"
15+
fi
16+
17+
echo "=> Setting timeout to ${REDIS_TIMEOUT}"
18+
echo timeout ${REDIS_TIMEOUT} >> /etc/redis/redis_default.conf
19+
20+
touch /.redis_configured
21+
fi
22+
523
if [ ! -f /.redis_password_set ]; then
6-
/set_redis_password.sh
24+
/set_redis_password.sh
725
fi
826

9-
exec /usr/bin/redis-server /etc/redis/redis_default.conf
27+
exec /usr/bin/redis-server /etc/redis/redis_default.conf

0 commit comments

Comments
 (0)