Redis using user and changed password logic to no password by default

This commit is contained in:
Miguel Martinez
2015-06-03 18:10:15 -07:00
parent e25bdc6644
commit e8047bb455
3 changed files with 22 additions and 33 deletions
+3 -1
View File
@@ -1,13 +1,15 @@
FROM ubuntu-debootstrap:14.04
MAINTAINER Bitnami
ENV BITNAMI_PREFIX=/usr/local/bitnami
ENV BITNAMI_APP_NAME redis
ENV BITNAMI_APP_VERSION 2.8.20-0
ENV BITNAMI_APP_DIR=$BITNAMI_PREFIX/$BITNAMI_APP_NAME
ADD https://storage.googleapis.com/bitnami-artifacts/install.sh?GoogleAccessId=432889337695-e1gggo94k5qubupjsb35tajs91bdu0hg@developer.gserviceaccount.com&Expires=1434934078&Signature=QNkAu%2F8E2RlalSQy4n1sxMhsGKF%2FVltr6zu65HU6A9H0HKOgl6u9etqy9w6OwD4DsLMxYuy2uymOK3iDc5RbfkAMncKI1zJpxcwRQ4Mt43Oe8PBXKbQYcZ7mQaYPtpnjYblDs1S2p12Pu5NTDJHK2hJ1MrIUYwBup5n60R6OJRI%3D /tmp/install.sh
ADD post-install.sh /tmp/post-install.sh
RUN stack=1 sh /tmp/install.sh --disable-components common
RUN stack=1 sh /tmp/install.sh --disable-components common --redis_enable_authentication 0
EXPOSE 6379
VOLUME ["/data", "/conf", "/logs"]
+18 -31
View File
@@ -2,46 +2,33 @@
set -e
if [ ! "$(ls -A /conf)" ]; then
cp -r /usr/local/bitnami/redis/etc/conf.defaults/* /usr/local/bitnami/redis/etc/conf
cp -r $BITNAMI_APP_DIR/etc/conf.defaults/* $BITNAMI_APP_DIR/etc/conf
if [ -z "$REDIS_PASSWORD" ]; then
REDIS_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c10)$(< /dev/urandom tr -dc 0-9 | head -c2)
RANDOM_PASSW=1
fi
if [ "$REDIS_PASSWORD" ]; then
echo "Setting password in /conf/redis.conf ..."
# TODO, move to bnconfig once password supported
sed -i -e 's:\W*\s*requirepass \S*:requirepass '$REDIS_PASSWORD':' /conf/redis.conf
# bnconfig depends on ctlscript file so we create it
# and remove it afterwards, TODO, fix
touch /usr/local/bitnami/ctlscript.sh
chmod a+x /usr/local/bitnami/ctlscript.sh
echo "Setting password in /conf/redis.conf ..."
/usr/local/bitnami/redis/bnconfig --userpassword $REDIS_PASSWORD
rm /usr/local/bitnami/ctlscript.sh
echo "#########################################################################"
echo "# #"
echo "# Credentials for redis: #"
echo "# password: $REDIS_PASSWORD #"
echo "# #"
if [ $RANDOM_PASSW ]; then
echo "# The password was generated automatically, if you want to use #"
echo "# your own password please set the REDIS_PASSWORD environment #"
echo "# variable when running the container. #"
echo "#########################################################################"
echo "# #"
echo "# Credentials for redis: #"
echo "# password: $REDIS_PASSWORD #"
echo "# #"
echo "#########################################################################"
fi
echo "#########################################################################"
else
echo "#########################################################################"
echo "# #"
echo "# Credentials for redis: #"
echo "# The REDIS_PASSWORD was added to /conf/redis.conf on first boot. #"
echo "# Please check \"requirepass\" option in that file. #"
echo "# If you want to regenerate the password recreate this container. #"
echo "# Container already initialized, skipping setup. #"
echo "# #"
echo "#########################################################################"
fi
chown -R redis:redis /data/ /logs/ /conf/
if [ "$1" = 'redis-server' ]; then
tail -f /logs/* &
exec gosu redis "$@"
fi
exec "$@"
+1 -1
View File
@@ -20,7 +20,7 @@ ln -s $INSTALL_DIR/var/data /data
ln -s $INSTALL_DIR/var/log /logs
# set up logging to stdout
ln -sf /dev/stdout /logs/redis-server.log
#ln -sf /dev/stdout /logs/redis-server.log
# Conf modifications
sed -i -e 's:\(dir '$INSTALL_DIR'/var\):\1/data:' $INSTALL_DIR/etc/conf.defaults/redis.conf