Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
beagle-rcache-image
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
market
beagle-rcache-image
Commits
f8e6700b
Commit
f8e6700b
authored
Jan 09, 2023
by
罗永亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Dockerfile, rcache.conf, entrypoint.sh, setupMasterSlave.sh, healthcheck.sh files
parent
3a7ef174
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
57 deletions
+56
-57
Dockerfile
Dockerfile
+6
-7
entrypoint.sh
entrypoint.sh
+33
-33
healthcheck.sh
healthcheck.sh
+6
-6
rcache.conf
rcache.conf
+0
-0
setupMasterSlave.sh
setupMasterSlave.sh
+11
-11
No files found.
Dockerfile
View file @
f8e6700b
...
@@ -12,7 +12,7 @@ ARG REDIS_VERSION="stable"
...
@@ -12,7 +12,7 @@ ARG REDIS_VERSION="stable"
RUN
apk add
--no-cache
su-exec tzdata make curl build-base linux-headers bash openssl-dev
RUN
apk add
--no-cache
su-exec tzdata make curl build-base linux-headers bash openssl-dev
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
https://dl.wodcloud.com/lyl/redis-stable/
&&
\
cd
/tmp
&&
\
cd
/tmp
&&
\
tar
xvzf redis-
${
REDIS_VERSION
}
.tar.gz
&&
\
tar
xvzf redis-
${
REDIS_VERSION
}
.tar.gz
&&
\
cd
redis-
${
REDIS_VERSION
}
&&
\
cd
redis-
${
REDIS_VERSION
}
&&
\
...
@@ -24,16 +24,15 @@ FROM alpine:3.15
...
@@ -24,16 +24,15 @@ FROM alpine:3.15
MAINTAINER
Opstree Solutions
MAINTAINER
Opstree Solutions
LABEL
VERSION=1.0 \
LABEL
VERSION=1.0 \
ARCH=AMD64 \
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
DESCRIPTION="A production grade performance tuned redis docker image created by Opstree Solutions"
COPY
--from=builder /usr/local/bin/r
edis-server /usr/local/bin/redis
-server
COPY
--from=builder /usr/local/bin/r
cache-server /usr/local/bin/rcache
-server
COPY
--from=builder /usr/local/bin/r
edis-cli /usr/local/bin/redis
-cli
COPY
--from=builder /usr/local/bin/r
cache-cli /usr/local/bin/rcache
-cli
RUN
addgroup
-S
-g
1000 r
edis
&&
adduser
-S
-G
redis
-u
1000 redis
&&
\
RUN
addgroup
-S
-g
1000 r
cache
&&
adduser
-S
-G
rcache
-u
1000 rcache
&&
\
apk add
--no-cache
bash
apk add
--no-cache
bash
COPY
redis.conf /etc/redis/redis
.conf
COPY
rcache.conf /etc/rcache/rcache
.conf
COPY
entrypoint.sh /usr/bin/entrypoint.sh
COPY
entrypoint.sh /usr/bin/entrypoint.sh
...
@@ -41,7 +40,7 @@ COPY setupMasterSlave.sh /usr/bin/setupMasterSlave.sh
...
@@ -41,7 +40,7 @@ COPY setupMasterSlave.sh /usr/bin/setupMasterSlave.sh
COPY
healthcheck.sh /usr/bin/healthcheck.sh
COPY
healthcheck.sh /usr/bin/healthcheck.sh
RUN
chown
-R
redis:redis /etc/redis
RUN
chown
-R
rcache:rcache /etc/rcache
VOLUME
["/data"]
VOLUME
["/data"]
...
...
entrypoint.sh
View file @
f8e6700b
...
@@ -4,46 +4,46 @@ set -a
...
@@ -4,46 +4,46 @@ set -a
PERSISTENCE_ENABLED
=
${
PERSISTENCE_ENABLED
:-
"false"
}
PERSISTENCE_ENABLED
=
${
PERSISTENCE_ENABLED
:-
"false"
}
DATA_DIR
=
${
DATA_DIR
:-
"/data"
}
DATA_DIR
=
${
DATA_DIR
:-
"/data"
}
EXTERNAL_CONFIG_FILE
=
${
EXTERNAL_CONFIG_FILE
:-
"/etc/r
edis/external.conf.d/redis
-additional.conf"
}
EXTERNAL_CONFIG_FILE
=
${
EXTERNAL_CONFIG_FILE
:-
"/etc/r
cache/external.conf.d/rcache
-additional.conf"
}
R
EDIS_MAJOR_VERSION
=
${
REDIS
_MAJOR_VERSION
:-
"v7"
}
R
CACHE_MAJOR_VERSION
=
${
RCACHE
_MAJOR_VERSION
:-
"v7"
}
apply_permissions
()
{
apply_permissions
()
{
chgrp
-R
1000 /etc/r
edis
chgrp
-R
1000 /etc/r
cache
chmod
-R
g
=
u /etc/r
edis
chmod
-R
g
=
u /etc/r
cache
}
}
common_operation
()
{
common_operation
()
{
mkdir
-p
"
${
DATA_DIR
}
"
mkdir
-p
"
${
DATA_DIR
}
"
mkdir
-p
"/etc/r
edis
/external.conf.d"
mkdir
-p
"/etc/r
cache
/external.conf.d"
touch
-p
"/etc/r
edis/external.conf.d/redis
-additional.conf"
touch
-p
"/etc/r
cache/external.conf.d/rcache
-additional.conf"
}
}
set_r
edis
_password
()
{
set_r
cache
_password
()
{
if
[[
-z
"
${
R
EDIS
_PASSWORD
}
"
]]
;
then
if
[[
-z
"
${
R
CACHE
_PASSWORD
}
"
]]
;
then
echo
"
Redis
is running without password which is not recommended"
echo
"
rcache
is running without password which is not recommended"
echo
"protected-mode no"
>>
/etc/r
edis/redis
.conf
echo
"protected-mode no"
>>
/etc/r
cache/rcache
.conf
else
else
{
{
echo
masterauth
"
${
R
EDIS
_PASSWORD
}
"
echo
masterauth
"
${
R
CACHE
_PASSWORD
}
"
echo
requirepass
"
${
R
EDIS
_PASSWORD
}
"
echo
requirepass
"
${
R
CACHE
_PASSWORD
}
"
echo
protected-mode
yes
echo
protected-mode
yes
}
>>
/etc/r
edis/redis
.conf
}
>>
/etc/r
cache/rcache
.conf
fi
fi
}
}
r
edis
_mode_setup
()
{
r
cache
_mode_setup
()
{
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
{
{
echo
cluster-enabled
yes
echo
cluster-enabled
yes
echo
cluster-require-full-coverage no
echo
cluster-require-full-coverage no
echo
cluster-migration-barrier 1
echo
cluster-migration-barrier 1
echo
cluster-config-file
"
${
DATA_DIR
}
/nodes.conf"
echo
cluster-config-file
"
${
DATA_DIR
}
/nodes.conf"
}
>>
/etc/r
edis/redis
.conf
}
>>
/etc/r
cache/rcache
.conf
POD_IP
=
$(
hostname
-i
)
POD_IP
=
$(
hostname
-i
)
sed
-i
-e
"/myself/ s/[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}
/
${
POD_IP
}
/"
"
${
DATA_DIR
}
/nodes.conf"
sed
-i
-e
"/myself/ s/[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}\.
[0-9]
\{
1,3
\}
/
${
POD_IP
}
/"
"
${
DATA_DIR
}
/nodes.conf"
else
else
echo
"Setting up r
edis
in standalone mode"
echo
"Setting up r
cache
in standalone mode"
fi
fi
}
}
...
@@ -52,18 +52,18 @@ tls_setup() {
...
@@ -52,18 +52,18 @@ tls_setup() {
{
{
echo
port 0
echo
port 0
echo
tls-port 6379
echo
tls-port 6379
echo
tls-cert-file
"
${
R
EDIS
_TLS_CERT
}
"
echo
tls-cert-file
"
${
R
CACHE
_TLS_CERT
}
"
echo
tls-key-file
"
${
R
EDIS
_TLS_CERT_KEY
}
"
echo
tls-key-file
"
${
R
CACHE
_TLS_CERT_KEY
}
"
echo
tls-ca-cert-file
"
${
R
EDIS
_TLS_CA_KEY
}
"
echo
tls-ca-cert-file
"
${
R
CACHE
_TLS_CA_KEY
}
"
# echo tls-prefer-server-ciphers yes
# echo tls-prefer-server-ciphers yes
echo
tls-auth-clients optional
echo
tls-auth-clients optional
}
>>
/etc/r
edis/redis
.conf
}
>>
/etc/r
cache/rcache
.conf
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
{
{
echo
tls-replication
yes
echo
tls-replication
yes
echo
tls-cluster
yes
echo
tls-cluster
yes
}
>>
/etc/r
edis/redis
.conf
}
>>
/etc/r
cache/rcache
.conf
fi
fi
else
else
echo
"Running without TLS mode"
echo
"Running without TLS mode"
...
@@ -79,38 +79,38 @@ persistence_setup() {
...
@@ -79,38 +79,38 @@ persistence_setup() {
echo
appendonly
yes
echo
appendonly
yes
echo
appendfilename
\"
appendonly.aof
\"
echo
appendfilename
\"
appendonly.aof
\"
echo dir
"
${
DATA_DIR
}
"
echo dir
"
${
DATA_DIR
}
"
}
>>
/etc/r
edis/redis
.conf
}
>>
/etc/r
cache/rcache
.conf
else
else
echo
"Running without persistence mode"
echo
"Running without persistence mode"
fi
fi
}
}
external_config
()
{
external_config
()
{
echo
"include
${
EXTERNAL_CONFIG_FILE
}
"
>>
/etc/r
edis/redis
.conf
echo
"include
${
EXTERNAL_CONFIG_FILE
}
"
>>
/etc/r
cache/rcache
.conf
}
}
start_r
edis
()
{
start_r
cache
()
{
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
if
[[
"
${
SETUP_MODE
}
"
==
"cluster"
]]
;
then
echo
"Starting r
edis
service in cluster mode....."
echo
"Starting r
cache
service in cluster mode....."
if
[[
"
${
R
EDIS
_MAJOR_VERSION
}
"
!=
"v7"
]]
;
then
if
[[
"
${
R
CACHE
_MAJOR_VERSION
}
"
!=
"v7"
]]
;
then
r
edis-server /etc/redis/redis
.conf
--cluster-announce-ip
"
${
POD_IP
}
"
r
cache-server /etc/rcache/rcache
.conf
--cluster-announce-ip
"
${
POD_IP
}
"
else
else
r
edis-server /etc/redis/redis
.conf
r
cache-server /etc/rcache/rcache
.conf
fi
fi
else
else
echo
"Starting r
edis
service in standalone mode....."
echo
"Starting r
cache
service in standalone mode....."
r
edis-server /etc/redis/redis
.conf
r
cache-server /etc/rcache/rcache
.conf
fi
fi
}
}
main_function
()
{
main_function
()
{
common_operation
common_operation
set_r
edis
_password
set_r
cache
_password
r
edis
_mode_setup
r
cache
_mode_setup
persistence_setup
persistence_setup
tls_setup
tls_setup
external_config
external_config
start_r
edis
start_r
cache
}
}
main_function
main_function
healthcheck.sh
View file @
f8e6700b
#!/bin/bash
#!/bin/bash
check_r
edis
_health
()
{
check_r
cache
_health
()
{
if
[[
-n
"
${
R
EDIS
_PASSWORD
}
"
]]
;
then
if
[[
-n
"
${
R
CACHE
_PASSWORD
}
"
]]
;
then
export
R
EDISCLI_AUTH
=
"
${
REDIS
_PASSWORD
}
"
export
R
CACHECLI_AUTH
=
"
${
RCACHE
_PASSWORD
}
"
fi
fi
if
[[
"
${
TLS_MODE
}
"
==
"true"
]]
;
then
if
[[
"
${
TLS_MODE
}
"
==
"true"
]]
;
then
r
edis-cli
--tls
--cert
"
${
REDIS_TLS_CERT
}
"
--key
"
${
REDIS_TLS_CERT_KEY
}
"
--cacert
"
${
REDIS
_TLS_CA_KEY
}
"
-h
"
$(
hostname
)
"
ping
r
cache-cli
--tls
--cert
"
${
RCACHE_TLS_CERT
}
"
--key
"
${
RCACHE_TLS_CERT_KEY
}
"
--cacert
"
${
RCACHE
_TLS_CA_KEY
}
"
-h
"
$(
hostname
)
"
ping
else
else
r
edis
-cli
-h
$(
hostname
)
ping
r
cache
-cli
-h
$(
hostname
)
ping
fi
fi
}
}
check_r
edis
_health
check_r
cache
_health
r
edis
.conf
→
r
cache
.conf
View file @
f8e6700b
File moved
setupMasterSlave.sh
View file @
f8e6700b
#!/bin/bash
#!/bin/bash
r
edis
_server_mode
()
{
r
cache
_server_mode
()
{
if
[[
"
${
SERVER_MODE
}
"
==
"master"
]]
;
then
if
[[
"
${
SERVER_MODE
}
"
==
"master"
]]
;
then
echo
"
Redis
server mode is master"
echo
" server mode is master"
if
[[
-z
"
${
R
EDIS
_PASSWORD
}
"
]]
;
then
if
[[
-z
"
${
R
CACHE
_PASSWORD
}
"
]]
;
then
r
edis
-cli
--cluster
create
"
${
MASTER_LIST
}
"
--cluster-yes
r
cache
-cli
--cluster
create
"
${
MASTER_LIST
}
"
--cluster-yes
else
else
r
edis-cli
--cluster
create
"
${
MASTER_LIST
}
"
--cluster-yes
-a
"
${
REDIS
_PASSWORD
}
"
r
cache-cli
--cluster
create
"
${
MASTER_LIST
}
"
--cluster-yes
-a
"
${
RCACHE
_PASSWORD
}
"
fi
fi
elif
[[
"
${
SERVER_MODE
}
"
==
"slave"
]]
;
then
elif
[[
"
${
SERVER_MODE
}
"
==
"slave"
]]
;
then
echo
"
Redis
server mode is slave"
echo
"
rcache
server mode is slave"
if
[[
-z
"
${
R
EDIS
_PASSWORD
}
"
]]
;
then
if
[[
-z
"
${
R
CACHE
_PASSWORD
}
"
]]
;
then
r
edis
-cli
--cluster
add-node
"
${
SLAVE_IP
}
"
"
${
MASTER_IP
}
"
--cluster-slave
r
cache
-cli
--cluster
add-node
"
${
SLAVE_IP
}
"
"
${
MASTER_IP
}
"
--cluster-slave
else
else
r
edis-cli
--cluster
add-node
"
${
SLAVE_IP
}
"
"
${
MASTER_IP
}
"
--cluster-slave
-a
"
${
REDIS
_PASSWORD
}
"
r
cache-cli
--cluster
add-node
"
${
SLAVE_IP
}
"
"
${
MASTER_IP
}
"
--cluster-slave
-a
"
${
RCACHE
_PASSWORD
}
"
fi
fi
else
else
echo
"
Redis
server mode is standalone"
echo
"
rcache
server mode is standalone"
fi
fi
}
}
r
edis
_server_mode
r
cache
_server_mode
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment