docker-redis - local tests
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -26,6 +26,9 @@ WORKDIR /app
|
|||||||
# Copy package.json and package-lock.json
|
# Copy package.json and package-lock.json
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install Nodemon
|
||||||
|
RUN npm install -g nodemon
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN npm install --omit=dev
|
RUN npm install --omit=dev
|
||||||
|
|
||||||
@@ -36,4 +39,4 @@ COPY . .
|
|||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["node", "server.js"]
|
CMD ["nodemon", "--legacy-watch", "server.js"]
|
||||||
|
|||||||
@@ -132,3 +132,4 @@ After editing the file, save it and then apply the new sysctl configuration by r
|
|||||||
```bash
|
```bash
|
||||||
sudo sysctl -p
|
sudo sysctl -p
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- "4000:4000"
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- /app/node_modules # Prevents overwriting node_modules
|
||||||
networks:
|
networks:
|
||||||
redis-cluster-net:
|
redis-cluster-net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
@@ -1,29 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
LOCK_FILE="redis-cluster-init.lock"
|
|
||||||
|
|
||||||
# Start Redis server in the background
|
# Start Redis server in the background
|
||||||
redis-server /usr/local/etc/redis/redis.conf &
|
redis-server /usr/local/etc/redis/redis.conf &
|
||||||
|
|
||||||
# Wait for Redis server to start
|
# Wait for Redis server to start
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Initialize the cluster only if the lock file does not exist
|
# Only initialize the cluster from one node to prevent race conditions
|
||||||
if [ ! -f "$LOCK_FILE" ]; then
|
if [ "$HOSTNAME" = "redis-node-1" ]; then
|
||||||
echo "Initializing Redis Cluster..."
|
echo "Initializing Redis Cluster..."
|
||||||
|
|
||||||
# Run the Redis cluster initialization
|
|
||||||
yes yes | redis-cli --cluster create \
|
yes yes | redis-cli --cluster create \
|
||||||
redis-node-1:6379 \
|
redis-node-1:6379 \
|
||||||
redis-node-2:6379 \
|
redis-node-2:6379 \
|
||||||
redis-node-3:6379 \
|
redis-node-3:6379 \
|
||||||
--cluster-replicas 0
|
--cluster-replicas 0
|
||||||
|
|
||||||
# Create the lock file after initialization
|
|
||||||
touch "$LOCK_FILE"
|
|
||||||
echo "Cluster initialization complete. Lock file created."
|
|
||||||
else
|
|
||||||
echo "Cluster has already been initialized. Skipping initialization."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Keep the container running
|
# Keep the container running
|
||||||
|
|||||||
Reference in New Issue
Block a user