{"id":15783622,"url":"https://github.com/deepmancer/redisinsight-docker-autoconfig","last_synced_at":"2025-04-01T16:30:50.105Z","repository":{"id":251720286,"uuid":"838244651","full_name":"deepmancer/redisinsight-docker-autoconfig","owner":"deepmancer","description":"Automates the configuration of Redis databases in RedisInsight using Docker. This setup simplifies the integration of multiple Redis instances for efficient management and monitoring.","archived":false,"fork":false,"pushed_at":"2024-08-16T12:03:57.000Z","size":16,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T20:02:55.728Z","etag":null,"topics":["automation","bash-scripting","configuration","docker","docker-compose","redis","redis-database","redisinsight","script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deepmancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T08:46:00.000Z","updated_at":"2024-08-26T08:51:51.000Z","dependencies_parsed_at":"2024-10-04T20:00:25.868Z","dependency_job_id":null,"html_url":"https://github.com/deepmancer/redisinsight-docker-autoconfig","commit_stats":null,"previous_names":["alirezaheidari-cs/redisinsight-docker-autoconfig","deepmancer/redisinsight-docker-autoconfig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fredisinsight-docker-autoconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fredisinsight-docker-autoconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fredisinsight-docker-autoconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deepmancer%2Fredisinsight-docker-autoconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deepmancer","download_url":"https://codeload.github.com/deepmancer/redisinsight-docker-autoconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620473,"owners_count":20806779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bash-scripting","configuration","docker","docker-compose","redis","redis-database","redisinsight","script"],"created_at":"2024-10-04T20:00:21.543Z","updated_at":"2025-04-01T16:30:49.806Z","avatar_url":"https://github.com/deepmancer.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 RedisInsight Docker Automated Configuration\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Redis-FF4438.svg?style=for-the-badge\u0026logo=Redis\u0026logoColor=white\" alt=\"Redis\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Docker-2496ED.svg?style=for-the-badge\u0026logo=Docker\u0026logoColor=white\" alt=\"Docker\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/shell_script-%23121011.svg?style=for-the-badge\u0026logo=gnu-bash\u0026logoColor=white\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Linux-FCC624.svg?style=for-the-badge\u0026logo=Linux\u0026logoColor=black\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/GNU%20Bash-4EAA25.svg?style=for-the-badge\u0026logo=GNU-Bash\u0026logoColor=white\"/\u003e\n\u003c/p\u003e\n\nWelcome to the **RedisInsight Docker AutoConfig** repository! This repository includes a Docker Compose setup for RedisInsight, alongside a powerful Bash script that automates the configuration of multiple Redis databases within RedisInsight. Simplify your workflow and let the script handle the heavy lifting for you!\n\n---\n\n## ✨ Features\n\nHere’s what the script does for you:\n1. **Network Configuration**: Automatically retrieves the gateway IP of your specified Docker network.\n2. **Initial Setup**: Applies essential settings to RedisInsight, including EULA acceptance.\n3. **Redis Integration**: Adds multiple Redis databases to RedisInsight in one go.\n\n## 🚨 Docker Compose Setup\n\nUse the following `docker-compose.yml` to set up your RedisInsight service:\n\n```yaml\nservices:\n  redis_insight:\n    image: \"redislabs/redisinsight:latest\"\n    container_name: redisinsight\n    ports:\n      - \"5540:5540\"\n    volumes:\n      - redis_insight_data:/data\n \nvolumes:\n  redis_insight_data:\n```\n\n---\n\n## 📝 Script Overview\n\nThe `add_datasources.sh` script automates adding Redis databases to RedisInsight via its API. Here’s what it covers:\n\n### 1. Configuration\n\nThe script starts by defining the API URL for RedisInsight and the Docker network name. It then retrieves the gateway IP for your specified network. If the network is not found, it defaults to `127.0.0.1`:\n\n```bash\nAPI_URL=\"http://localhost:5540/api\"\nNETWORK_NAME=\"backend-network\"\n\nGATEWAY_IP=$(docker network inspect \"$NETWORK_NAME\" --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}')\n\nif [ -z \"$GATEWAY_IP\" ]; then\n  echo \"Warning: Unable to retrieve gateway IP for network '$NETWORK_NAME'. Using 127.0.0.1 as the default.\"\n  GATEWAY_IP=\"127.0.0.1\"\nfi\n\necho \"Gateway IP for network '$NETWORK_NAME' is $GATEWAY_IP\"\n```\n\n### 2. Apply Initial Settings\n\nThe script applies essential settings to RedisInsight, such as accepting the EULA and disabling analytics:\n\n```bash\nSETTINGS_PAYLOAD='{\n  \"agreements\": {\n    \"eula\": true,\n    \"analytics\": false,\n    \"notifications\": false,\n    \"encryption\": false\n  }\n}'\n\ncurl -X GET \"${API_URL}/settings\"      -H \"Content-Type: application/json\"      -d \"$SETTINGS_PAYLOAD\" \u003e /dev/null 2\u003e\u00261\n```\n\n### 3. Define and Add Redis Databases\n\nThe script iterates over a list of Redis instances, adding each one to RedisInsight:\n\n```bash\n# Redis instances configuration\nREDIS_INSTANCES=(\n  \"Gateway Redis|6490|gateway_password|gateway_redis\"\n  \"User Redis|6235|user_password|user_redis\"\n  \"Restaurant Redis|6236|restaurant_password|restaurant_redis\"\n  \"Location Redis|6300|location_password|location_redis\"\n  \"Order Redis|6301|order_password|order_redis\"\n)\n\n# Function to add a Redis database to RedisInsight\nadd_redis_database() {\n  local NAME=$1\n  local PORT=$2\n  local PASSWORD=$3\n  local DB_NAME=$4\n\n  echo \"Adding Redis database: $NAME...\"\n\n  curl -s -X POST \"${API_URL}/databases\"        -H \"Content-Type: application/json\"        -d \"{\n            \"host\": \"${GATEWAY_IP}\",\n            \"port\": ${PORT},\n            \"password\": \"${PASSWORD}\",\n            \"name\": \"${DB_NAME}\"\n          }\" \u003e /dev/null\n\n  if [ $? -eq 0 ]; then\n    echo \"Successfully added Redis database: $NAME\"\n  else\n    echo \"Error: Failed to add Redis database: $NAME\"\n  fi\n}\n\n# Iterate over the Redis instances and add them to RedisInsight\nfor redis in \"${REDIS_INSTANCES[@]}\"; do\n  IFS='|' read -r REDIS_NAME REDIS_PORT REDIS_PASSWORD REDIS_DB_NAME \u003c\u003c\u003c \"$redis\"\n  add_redis_database \"$REDIS_NAME\" \"$REDIS_PORT\" \"$REDIS_PASSWORD\" \"$REDIS_DB_NAME\"\ndone\n\necho \"All Redis databases have been added successfully.\"\n```\n\n---\n\n## 🚀 How to Use\n\n1. **Customize the Script**: Edit the configuration variables to match your RedisInsight setup and Docker network. Modify the `REDIS_INSTANCES` array to include your Redis databases.\n\n2. **Run the Script**: Make the script executable and run it:\n\n    ```bash\n    chmod +x add_datasources.sh\n    ./add_datasources.sh\n    ```\n\n3. **Verify the Results**: Log into RedisInsight and check that your databases have been added successfully.\n\n![image](https://github.com/user-attachments/assets/f6276046-624e-4690-bc28-d0d5df9a1eac)\n\n---\n\n## 📜 License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Fredisinsight-docker-autoconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeepmancer%2Fredisinsight-docker-autoconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeepmancer%2Fredisinsight-docker-autoconfig/lists"}