Commit 5c5c7946 authored by iamabhishek-dubey's avatar iamabhishek-dubey

Changed image architecture

parent 59f78231
...@@ -10,7 +10,7 @@ ARG REDIS_DOWNLOAD_URL="http://download.redis.io/" ...@@ -10,7 +10,7 @@ ARG REDIS_DOWNLOAD_URL="http://download.redis.io/"
ARG REDIS_VERSION="stable" ARG REDIS_VERSION="stable"
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 999 redis && \ RUN addgroup -S -g 1001 redis && adduser -S -G redis -u 1001 redis && \
apk add --no-cache su-exec tzdata make curl build-base linux-headers bash apk add --no-cache su-exec tzdata make curl build-base linux-headers bash
RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \ RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-${REDIS_VERSION}.tar.gz && \
...@@ -21,14 +21,21 @@ RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis- ...@@ -21,14 +21,21 @@ RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-
make install && \ make install && \
mkdir -p /etc/redis && \ mkdir -p /etc/redis && \
cp -f *.conf /etc/redis && \ cp -f *.conf /etc/redis && \
rm -rf /tmp/redis-${REDIS_VERSION}* rm -rf /tmp/redis-${REDIS_VERSION}* && \
apk del curl make
COPY redis.conf /etc/redis/redis.conf
COPY entrypoint.sh /usr/bin/entrypoint.sh COPY entrypoint.sh /usr/bin/entrypoint.sh
COPY run.sh /usr/bin/run.sh
VOLUME ["/data"] VOLUME ["/data"]
WORKDIR /data WORKDIR /data
USER redis
EXPOSE 6379 EXPOSE 6379
ENTRYPOINT ["/usr/bin/entrypoint.sh"] ENTRYPOINT ["/usr/bin/entrypoint.sh"]
#!/bin/bash #!/bin/bash
set -eu set -ex
generate_common_config() {
{
echo "bind 0.0.0.0"
echo protected-mode yes
echo tcp-backlog 511
echo timeout 0
echo tcp-keepalive 300
echo daemonize no
echo supervised no
echo pidfile /var/run/redis.pid
} > /etc/redis/redis.conf
}
set_redis_password() { set_redis_password() {
if [ -z "${REDIS_PASSWORD}" ]; then if [[ -z "${REDIS_PASSWORD}" ]]; then
echo "Redis is running without password which is not recommended" echo "Redis is running without password which is not recommended"
else else
{ {
...@@ -27,7 +14,7 @@ set_redis_password() { ...@@ -27,7 +14,7 @@ set_redis_password() {
} }
redis_mode_setup() { redis_mode_setup() {
if [ "${SETUP_MODE}" = "cluster" ]; then if [[ "${SETUP_MODE}" == "cluster" ]]; then
{ {
echo cluster-enabled yes echo cluster-enabled yes
echo cluster-config-file nodes.conf echo cluster-config-file nodes.conf
...@@ -39,15 +26,15 @@ redis_mode_setup() { ...@@ -39,15 +26,15 @@ redis_mode_setup() {
} }
start_redis() { start_redis() {
echo "Starting redis service " echo "Starting redis service....."
redis-server /etc/redis/redis.conf redis-server /etc/redis/redis.conf
} }
main_function() { main_function() {
generate_common_config
set_redis_password set_redis_password
redis_mode_setup redis_mode_setup
start_redis start_redis
redis_server_mode
} }
main_function main_function
bind 0.0.0.0
protected-mode yes
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis.pid
#!/bin/bash
redis_server_mode() {
if [[ "${SERVER_MODE}" == "master" ]]; then
echo "Redis server mode is master"
elif [[ "${SERVER_MODE}" == "slave" ]]; then
echo "Redis server mode is slave"
if [[ -z "${REDIS_PASSWORD}" ]]; then
redis-cli --add-node "${SLAVE_IP}" "${MASTER_IP}" --cluster-slave
else
redis-cli --add-node "${SLAVE_IP}" "${MASTER_IP}" --cluster-slave -a "${REDIS_PASSWORD}"
fi
else
echo "Redis server mode is standalone"
fi
}
redis_server_mode
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment