docker-redis - improve lockfile for redis, add redis-insights, make sure app image has all it needs to build canvas
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -18,6 +18,8 @@ RUN dnf install -y \
|
||||
giflib-devel \
|
||||
libpng-devel \
|
||||
make \
|
||||
python3 \
|
||||
python3-pip \
|
||||
&& dnf clean all
|
||||
|
||||
# Set the working directory
|
||||
@@ -39,4 +41,4 @@ COPY . .
|
||||
EXPOSE 4000
|
||||
|
||||
# Start the application
|
||||
CMD ["nodemon", "--legacy-watch", "server.js"]
|
||||
CMD ["nodemon", "--exitcrash" , "--legacy-watch", "server.js"]
|
||||
|
||||
@@ -1,55 +1,60 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
redis-node-1:
|
||||
build:
|
||||
context: ./redis
|
||||
container_name: redis-node-1
|
||||
hostname: redis-node-1
|
||||
restart: always
|
||||
networks:
|
||||
- redis-cluster-net
|
||||
volumes:
|
||||
- ./redis/dockerdata/redis-node-1:/data
|
||||
- ./redis/dockerdata/lock:/redis-lock
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
redis-node-2:
|
||||
build:
|
||||
context: ./redis
|
||||
container_name: redis-node-2
|
||||
hostname: redis-node-2
|
||||
restart: always
|
||||
networks:
|
||||
- redis-cluster-net
|
||||
volumes:
|
||||
- ./redis/dockerdata/redis-node-2:/data
|
||||
- ./redis/dockerdata/lock:/redis-lock
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
redis-node-3:
|
||||
build:
|
||||
context: ./redis
|
||||
container_name: redis-node-3
|
||||
hostname: redis-node-3
|
||||
restart: always
|
||||
networks:
|
||||
- redis-cluster-net
|
||||
volumes:
|
||||
- ./redis/dockerdata/redis-node-3:/data
|
||||
- ./redis/dockerdata/lock:/redis-lock
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
node-app:
|
||||
build:
|
||||
context: .
|
||||
container_name: node-app
|
||||
hostname: imex-api
|
||||
networks:
|
||||
- redis-cluster-net
|
||||
env_file:
|
||||
@@ -65,7 +70,7 @@ services:
|
||||
- "4000:4000"
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules # Prevents overwriting node_modules
|
||||
- /app/node_modules
|
||||
|
||||
socketio-admin-ui:
|
||||
image: maitrungduc1410/socket.io-admin-ui
|
||||
@@ -74,6 +79,16 @@ services:
|
||||
- redis-cluster-net
|
||||
ports:
|
||||
- "3333:80"
|
||||
|
||||
redis-insight:
|
||||
image: redislabs/redisinsight:latest
|
||||
container_name: redis-insight
|
||||
hostname: redis-insight
|
||||
restart: always
|
||||
ports:
|
||||
- "3334:5540"
|
||||
networks:
|
||||
- redis-cluster-net
|
||||
|
||||
networks:
|
||||
redis-cluster-net:
|
||||
|
||||
5
redis/dockerdata/.gitignore
vendored
5
redis/dockerdata/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*
|
||||
!lock\
|
||||
lock\redis-cluster-init.lock
|
||||
!lock/
|
||||
lock/*
|
||||
!lock/.gitkeep
|
||||
|
||||
0
redis/dockerdata/lock/.gitkeep
Normal file
0
redis/dockerdata/lock/.gitkeep
Normal file
@@ -1,19 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOCKFILE="/redis-lock/redis-cluster-init.lock"
|
||||
|
||||
# Start Redis server in the background
|
||||
redis-server /usr/local/etc/redis/redis.conf &
|
||||
|
||||
# Wait for Redis server to start
|
||||
sleep 5
|
||||
|
||||
# Only initialize the cluster from one node to prevent race conditions
|
||||
if [ "$HOSTNAME" = "redis-node-1" ]; then
|
||||
# Only initialize the cluster if the lock file doesn't exist
|
||||
if [ ! -f "$LOCKFILE" ]; then
|
||||
echo "Initializing Redis Cluster..."
|
||||
|
||||
# Create lock file to prevent further initialization attempts
|
||||
touch "$LOCKFILE"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Lock file created successfully at $LOCKFILE."
|
||||
else
|
||||
echo "Failed to create lock file."
|
||||
fi
|
||||
|
||||
# Initialize the Redis cluster
|
||||
yes yes | redis-cli --cluster create \
|
||||
redis-node-1:6379 \
|
||||
redis-node-2:6379 \
|
||||
redis-node-3:6379 \
|
||||
--cluster-replicas 0
|
||||
|
||||
echo "Redis Cluster initialized."
|
||||
else
|
||||
echo "Cluster already initialized, skipping initialization."
|
||||
fi
|
||||
|
||||
# Keep the container running
|
||||
|
||||
Reference in New Issue
Block a user