Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added standalone,sentinel and cluster compose files and updated workflow #251

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MuhammadQadora
Copy link

@MuhammadQadora MuhammadQadora commented Dec 26, 2024

fix #250

Summary by CodeRabbit

  • New Features

    • Introduced multiple Redis configurations: standalone, replication, and cluster instances.
    • Added new services for Redis cluster nodes (node0 to node5) and Redis Sentinel instances.
    • Implemented a standalone Redis service for external access.
  • Bug Fixes

    • Enhanced workflow to ensure proper resolution of Redis service names.
  • Documentation

    • Updated Docker Compose configurations for improved clarity and organization.

@MuhammadQadora MuhammadQadora linked an issue Dec 26, 2024 that may be closed by this pull request
Copy link

coderabbitai bot commented Dec 26, 2024

Walkthrough

The pull request introduces comprehensive Docker Compose configurations for Redis environments, specifically adding support for standalone, sentinel, and cluster configurations. The changes include creating three new Docker Compose files in the docker directory: standalone-compose.yml, sentinel-compose.yml, and cluster-compose.yml. These configurations use the falkordb/falkordb:edge image and set up various Redis service topologies with specific networking and configuration requirements. The GitHub Actions workflow has been updated to integrate these new Docker Compose setups.

Changes

File Change Summary
.github/workflows/node.js.yml Updated workflow to use Docker Compose for multiple Redis configurations, added host file modifications and Docker Compose client installation
docker/standalone-compose.yml Added standalone Redis service with port 6379 mapping
docker/sentinel-compose.yml Added 3 Sentinel and 2 Redis server instances with master-replica configuration
docker/cluster-compose.yml Added 6-node Redis cluster configuration with network and health checks

Assessment against linked issues

Objective Addressed Explanation
Create Docker Compose for Redis cluster [#250]
Create Docker Compose for Redis Sentinel [#250]
Create Docker Compose for standalone Redis [#250]

Poem

🐰 Hoppity hop, Redis configs galore,
Clusters and sentinels knock at the door,
Standalone, replication, we've got the might,
Docker Compose dancing with pure delight!
Redis services spinning, oh what a sight! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.08%. Comparing base (622cfee) to head (e9e73f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #251   +/-   ##
=======================================
  Coverage   63.08%   63.08%           
=======================================
  Files          22       22           
  Lines         531      531           
  Branches       84       84           
=======================================
  Hits          335      335           
  Misses        190      190           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (6)
.github/workflows/node.js.yml (2)

38-48: Simplify host file modifications using a loop

The current approach of adding hosts individually can be simplified using a loop for all services.

     - name: Add entries to the host file to correctly resolve service names
       run: |
-        sudo echo "127.0.0.1 redis-standalone" | sudo tee -a /etc/hosts
-        sudo echo "127.0.0.1 sentinel-1"       | sudo tee -a /etc/hosts
-        sudo echo "127.0.0.1 sentinel-2"       | sudo tee -a /etc/hosts
-        sudo echo "127.0.0.1 sentinel-3"       | sudo tee -a /etc/hosts
-        sudo echo "127.0.0.1 redis-server-1"   | sudo tee -a /etc/hosts
-        sudo echo "127.0.0.1 redis-server-2"   | sudo tee -a /etc/hosts
-        for i in node{0..5};do
-          echo "127.0.0.1 $i" | sudo tee -a /etc/hosts
-        done
+        services=("redis-standalone" "sentinel-1" "sentinel-2" "sentinel-3" "redis-server-1" "redis-server-2" $(seq -f "node%g" 0 5))
+        for service in "${services[@]}"; do
+          echo "127.0.0.1 $service" | sudo tee -a /etc/hosts
+        done

50-51: Remove redundant docker-compose installation

The hoverkraft-tech/compose-action action already includes Docker Compose, making this step unnecessary.

-    - name: install docker-compose client
-      run: sudo apt update && sudo apt install docker-compose -y
docker/sentinel-compose.yml (1)

107-108: Add network configuration details

Specify the network driver and subnet for better control over the Redis Sentinel network.

 networks:
   redis-sentinel:
+    driver: bridge
+    ipam:
+      config:
+        - subnet: 172.28.0.0/16
docker/cluster-compose.yml (3)

145-146: Enhance network configuration for production use

The network configuration lacks important production settings:

  • Network driver specification
  • Network configuration options
  • Network name uniqueness guarantee

Consider enhancing the network configuration:

 networks:
   redis-cluster:
+    name: ${COMPOSE_PROJECT_NAME:-falkordb}_redis_cluster
+    driver: overlay  # for Swarm mode, or 'bridge' for standalone
+    driver_opts:
+      com.docker.network.driver.mtu: 1400
+    internal: true  # prevent external access
🧰 Tools
🪛 yamllint (1.35.1)

[error] 146-146: no new line character at the end of file

(new-line-at-end-of-file)


1-146: Document and enhance the cluster architecture

The cluster configuration would benefit from:

  1. Documentation explaining:
    • Cluster topology (3 masters, 3 replicas)
    • Port assignments
    • Setup requirements
  2. Security considerations:
    • Redis password/ACL configuration
    • Network security
  3. Configuration flexibility using environment variables

Consider adding a README.md in the docker directory with setup instructions and creating an example .env file:

# Redis Cluster Setup

This configuration creates a 6-node Redis cluster with 3 master nodes and 3 replica nodes.

## Configuration

Copy `.env.example` to `.env` and adjust the values:

```env
REDIS_PASSWORD=your_secure_password
REDIS_VERSION=latest
REDIS_PORT_START=5000
REDIS_REPLICA_COUNT=1

Usage

docker compose -f cluster-compose.yml up -d

Would you like me to help create this documentation and environment configuration?

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 yamllint (1.35.1)</summary>

[warning] 11-11: wrong indentation: expected 6 but found 10

(indentation)

---

[error] 146-146: no new line character at the end of file

(new-line-at-end-of-file)

</details>

</details>

---

`11-11`: **Fix formatting issues**

The following formatting issues were detected:
1. Incorrect indentation in healthcheck section (line 11)
2. Missing newline at end of file (line 146)


Apply these formatting fixes:

```diff
       healthcheck:
-          test: |
+        test: |
           redis-cli --cluster create node0:5000 node1:6000 \
 
 networks:
   redis-cluster:
+

Also applies to: 146-146

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 11-11: wrong indentation: expected 6 but found 10

(indentation)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 622cfee and e9e73f1.

📒 Files selected for processing (4)
  • .github/workflows/node.js.yml (1 hunks)
  • docker/cluster-compose.yml (1 hunks)
  • docker/sentinel-compose.yml (1 hunks)
  • docker/standalone-compose.yml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/node.js.yml

[error] 37-37: trailing spaces

(trailing-spaces)


[error] 49-49: trailing spaces

(trailing-spaces)


[error] 58-58: trailing spaces

(trailing-spaces)

docker/cluster-compose.yml

[warning] 11-11: wrong indentation: expected 6 but found 10

(indentation)


[error] 146-146: no new line character at the end of file

(new-line-at-end-of-file)

docker/sentinel-compose.yml

[error] 13-13: trailing spaces

(trailing-spaces)


[error] 45-45: trailing spaces

(trailing-spaces)


[error] 81-81: trailing spaces

(trailing-spaces)


[error] 86-86: trailing spaces

(trailing-spaces)


[error] 100-100: trailing spaces

(trailing-spaces)

Comment on lines +1 to +7
services:
redis-standalone:
container_name: redis-standalone
hostname: redis-standalone
image: falkordb/falkordb:edge
ports:
- 6379:6379
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add essential container configurations for production readiness

The standalone Redis configuration needs several important additions for production deployment:

  1. Volume persistence to prevent data loss
  2. Health check for container orchestration
  3. Resource limits to prevent resource exhaustion
  4. Restart policy for automatic recovery
 services:
   redis-standalone:
     container_name: redis-standalone
     hostname: redis-standalone
     image: falkordb/falkordb:edge
     ports:
       - 6379:6379
+    volumes:
+      - redis-data:/data
+    healthcheck:
+      test: ["CMD", "redis-cli", "ping"]
+      interval: 10s
+      timeout: 5s
+      retries: 3
+    deploy:
+      resources:
+        limits:
+          memory: 1G
+    restart: unless-stopped
+
+volumes:
+  redis-data:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
services:
redis-standalone:
container_name: redis-standalone
hostname: redis-standalone
image: falkordb/falkordb:edge
ports:
- 6379:6379
services:
redis-standalone:
container_name: redis-standalone
hostname: redis-standalone
image: falkordb/falkordb:edge
ports:
- 6379:6379
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
deploy:
resources:
limits:
memory: 1G
restart: unless-stopped
volumes:
redis-data:

redis-standalone:
container_name: redis-standalone
hostname: redis-standalone
image: falkordb/falkordb:edge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Consider using the stable version v4.4.1 instead of 'edge'

Using the edge tag can lead to unexpected behavior as it always pulls the latest build. Based on the available tags from Docker Hub, I recommend using v4.4.1 which is the latest stable version. This will ensure better stability and reproducibility of your deployment.

Example:

image: falkordb/falkordb:v4.4.1
🔗 Analysis chain

Consider using a specific version tag instead of 'edge'

Using the edge tag can lead to unexpected behavior as it always pulls the latest build. Consider using a specific version tag for better stability and reproducibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check available FalkorDB tags
curl -s https://registry.hub.docker.com/v2/repositories/falkordb/falkordb/tags | jq -r '.results[].name'

Length of output: 206

Comment on lines +23 to +36
- name: Run docker-compose for redis standalone instance
uses: hoverkraft-tech/[email protected]
with:
compose-file: ./docker/standalone-compose.yml

- name: Run docker-compose for redis replication instance
uses: hoverkraft-tech/[email protected]
with:
compose-file: ./docker/sentinel-compose.yml

- name: Run docker-compose for redis cluster instance
uses: hoverkraft-tech/[email protected]
with:
compose-file: ./docker/cluster-compose.yml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add service health checks before running tests

The workflow starts multiple Redis instances but doesn't verify if they're ready before proceeding. Add health checks to ensure services are fully operational.

     - name: Run docker-compose for redis standalone instance
       uses: hoverkraft-tech/[email protected]
       with:
         compose-file: ./docker/standalone-compose.yml
+    - name: Wait for standalone Redis to be ready
+      run: |
+        timeout 30s bash -c 'until redis-cli ping; do sleep 1; done'

     - name: Run docker-compose for redis replication instance
       uses: hoverkraft-tech/[email protected]
       with:
         compose-file: ./docker/sentinel-compose.yml
+    - name: Wait for sentinel setup to be ready
+      run: |
+        timeout 60s bash -c 'until redis-cli -p 26379 ping; do sleep 1; done'

     - name: Run docker-compose for redis cluster instance
       uses: hoverkraft-tech/[email protected]
       with:
         compose-file: ./docker/cluster-compose.yml
+    - name: Wait for cluster to be ready
+      run: |
+        timeout 60s bash -c 'until redis-cli cluster info; do sleep 1; done'

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +15 to +22
touch /data/sentinel.conf
echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf
echo "sentinel announce-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-ip sentinel-1" >> /data/sentinel.conf
echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-port 26379" >> /data/sentinel.conf
echo "port 26379" >> /data/sentinel.conf
redis-server /data/sentinel.conf --sentinel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance Sentinel configuration with additional parameters

The current Sentinel configuration lacks important parameters for production deployment:

  • down-after-milliseconds: Timeout to mark node as down
  • failover-timeout: Time before triggering failover
  • parallel-syncs: Number of replicas that can sync simultaneously
         touch /data/sentinel.conf
         echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf
+        echo "sentinel down-after-milliseconds master 5000"  >> /data/sentinel.conf
+        echo "sentinel failover-timeout master 60000"        >> /data/sentinel.conf
+        echo "sentinel parallel-syncs master 1"             >> /data/sentinel.conf
         echo "sentinel announce-hostnames yes"               >> /data/sentinel.conf
         echo "sentinel announce-ip sentinel-1"               >> /data/sentinel.conf
         echo "sentinel resolve-hostnames yes"                >> /data/sentinel.conf
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
touch /data/sentinel.conf
echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf
echo "sentinel announce-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-ip sentinel-1" >> /data/sentinel.conf
echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-port 26379" >> /data/sentinel.conf
echo "port 26379" >> /data/sentinel.conf
redis-server /data/sentinel.conf --sentinel
touch /data/sentinel.conf
echo "sentinel monitor master redis-server-1 6380 2" >> /data/sentinel.conf
echo "sentinel down-after-milliseconds master 5000" >> /data/sentinel.conf
echo "sentinel failover-timeout master 60000" >> /data/sentinel.conf
echo "sentinel parallel-syncs master 1" >> /data/sentinel.conf
echo "sentinel announce-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-ip sentinel-1" >> /data/sentinel.conf
echo "sentinel resolve-hostnames yes" >> /data/sentinel.conf
echo "sentinel announce-port 26379" >> /data/sentinel.conf
echo "port 26379" >> /data/sentinel.conf
redis-server /data/sentinel.conf --sentinel

Comment on lines +68 to +85
redis-server-1:
image: falkordb/falkordb:edge
hostname: redis-server-1
container_name: redis-server-1
ports:
- 6380:6380
networks:
- redis-sentinel
entrypoint: /bin/bash
command:
- -c
- |
touch /data/node.conf
echo "port 6380" >> /data/node.conf
echo "replica-announce-ip redis-server-1" >> /data/node.conf
echo "replica-announce-port 6380" >> /data/node.conf
echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf
redis-server /data/node.conf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add persistence and security configurations for Redis master

The Redis master configuration needs additional settings for durability and security:

  • Data persistence
  • Password protection
  • Memory limits
         touch /data/node.conf
         echo "port 6380" >> /data/node.conf 
+        echo "requirepass your_redis_password" >> /data/node.conf
+        echo "masterauth your_redis_password" >> /data/node.conf
+        echo "maxmemory 1gb" >> /data/node.conf
+        echo "maxmemory-policy allkeys-lru" >> /data/node.conf
+        echo "appendonly yes" >> /data/node.conf
+        echo "appendfsync everysec" >> /data/node.conf
         echo "replica-announce-ip redis-server-1"       >> /data/node.conf
         echo "replica-announce-port 6380"               >> /data/node.conf
         echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf

Also, add volume configuration:

     image: falkordb/falkordb:edge
     hostname: redis-server-1
     container_name: redis-server-1
+    volumes:
+      - redis-master-data:/data
     ports:
       - 6380:6380
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
redis-server-1:
image: falkordb/falkordb:edge
hostname: redis-server-1
container_name: redis-server-1
ports:
- 6380:6380
networks:
- redis-sentinel
entrypoint: /bin/bash
command:
- -c
- |
touch /data/node.conf
echo "port 6380" >> /data/node.conf
echo "replica-announce-ip redis-server-1" >> /data/node.conf
echo "replica-announce-port 6380" >> /data/node.conf
echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf
redis-server /data/node.conf
redis-server-1:
image: falkordb/falkordb:edge
hostname: redis-server-1
container_name: redis-server-1
volumes:
- redis-master-data:/data
ports:
- 6380:6380
networks:
- redis-sentinel
entrypoint: /bin/bash
command:
- -c
- |
touch /data/node.conf
echo "port 6380" >> /data/node.conf
echo "requirepass your_redis_password" >> /data/node.conf
echo "masterauth your_redis_password" >> /data/node.conf
echo "maxmemory 1gb" >> /data/node.conf
echo "maxmemory-policy allkeys-lru" >> /data/node.conf
echo "appendonly yes" >> /data/node.conf
echo "appendfsync everysec" >> /data/node.conf
echo "replica-announce-ip redis-server-1" >> /data/node.conf
echo "replica-announce-port 6380" >> /data/node.conf
echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf
redis-server /data/node.conf
🧰 Tools
🪛 yamllint (1.35.1)

[error] 81-81: trailing spaces

(trailing-spaces)

@@ -0,0 +1,146 @@
services:
node0:
image: falkordb/falkordb:edge
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix critical issues in healthcheck configuration and image tag

  1. The edge tag is not recommended for production use as it may contain unstable changes. Consider using a specific version tag.
  2. The healthcheck has several issues:
    • The command || echo failed && exit 1 doesn't work as intended due to shell operator precedence
    • No dependency management between nodes
    • No wait for other nodes to be ready before cluster creation

Consider these fixes:

-    image: falkordb/falkordb:edge
+    image: falkordb/falkordb:latest  # or specific version tag
     # ... other configs ...
     healthcheck:
           test: |
-            redis-cli --cluster create node0:5000 node1:6000 \
-              node2:7000 node3:8000 node4:9000 node5:10000 --cluster-replicas 1 --cluster-yes || echo failed && exit 1
+            timeout 5 bash -c '
+              until redis-cli -h node1 -p 6000 ping && \
+                    redis-cli -h node2 -p 7000 ping && \
+                    redis-cli -h node3 -p 8000 ping && \
+                    redis-cli -h node4 -p 9000 ping && \
+                    redis-cli -h node5 -p 10000 ping; do
+                sleep 1
+              done
+              redis-cli --cluster create node0:5000 node1:6000 \
+                node2:7000 node3:8000 node4:9000 node5:10000 \
+                --cluster-replicas 1 --cluster-yes || exit 1'

Also applies to: 10-17

Comment on lines +22 to +31
touch /data/node.conf
echo "port 5000" >> /data/node.conf
echo "loadmodule /FalkorDB/bin/src/falkordb.so" >> /data/node.conf
echo "cluster-preferred-endpoint-type hostname" >> /data/node.conf
echo "cluster-port 16379" >> /data/node.conf
echo "cluster-enabled yes" >> /data/node.conf
echo "cluster-config-file /data/nodes.conf" >> /data/node.conf
echo "cluster-node-timeout 5000" >> /data/node.conf
echo "cluster-announce-hostname node0" >> /data/node.conf
redis-server /data/node.conf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve configuration management and production readiness

  1. The node configurations are heavily duplicated. Consider using Docker Compose extensions to define a common template.
  2. Missing important production configurations:
    • No volume mounts for data persistence
    • No restart policy defined
    • No resource limits

Consider refactoring using this pattern:

x-node-template: &node-template
  image: falkordb/falkordb:latest
  networks:
    - redis-cluster
  restart: unless-stopped
  volumes:
    - redis-data:/data
  entrypoint: /bin/bash
  command:
    - -c
    - |
      touch /data/node.conf
      cat > /data/node.conf << EOF
      port ${PORT}
      loadmodule /FalkorDB/bin/src/falkordb.so
      cluster-preferred-endpoint-type hostname
      cluster-port 16379
      cluster-enabled yes
      cluster-config-file /data/nodes.conf
      cluster-node-timeout 5000
      cluster-announce-hostname ${HOSTNAME}
      EOF
      redis-server /data/node.conf

services:
  node0:
    <<: *node-template
    environment:
      - PORT=5000
    ports:
      - "${PORT}:${PORT}"
    # ... other specific configs

volumes:
  redis-data:

Also applies to: 44-53, 66-75, 88-97, 110-119, 133-142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add sentinel and cluster support for tests
1 participant