services:
redis-enterprise:
image: ${REDIS_ENTERPRISE_IMAGE:-redislabs/redis:8.2.0-25.12}
tty: true
cap_add:
- ALL
ports:
- "${REDIS_ENTERPRISE_DB_PORT:-12000}:12000" - "${REDIS_ENTERPRISE_API_PORT:-9443}:9443" - "${REDIS_ENTERPRISE_UI_PORT:-8443}:8443" healthcheck:
test: ["CMD", "curl", "-f", "-k", "https://localhost:9443/v1/bootstrap"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
init:
image: ${REDISCTL_IMAGE:-ghcr.io/redis-developer/redisctl@sha256:2d8b5148226705ae4c057611c4adcd2c9ba08cac0c02cec1c449fc31b92a2026}
depends_on:
redis-enterprise:
condition: service_healthy
environment:
REDIS_ENTERPRISE_URL: "https://redis-enterprise:9443"
REDIS_ENTERPRISE_USER: "admin@redis.local"
REDIS_ENTERPRISE_PASSWORD: "Redis123!"
REDIS_ENTERPRISE_INSECURE: "true"
REDIS_ENTERPRISE_DATABASE_VERSION: "${REDIS_ENTERPRISE_DATABASE_VERSION:-}"
entrypoint: ["/bin/sh", "-ec"]
command:
- |
redisctl enterprise workflow init-cluster \
--name test-cluster \
--username admin@redis.local \
--password 'Redis123!' \
--skip-database
database_data='{"name":"default-db","memory_size":1073741824,"type":"redis","replication":false}'
if [ -n "$$REDIS_ENTERPRISE_DATABASE_VERSION" ]; then
database_data=$$(printf \
'{"name":"default-db","memory_size":1073741824,"type":"redis","replication":false,"redis_version":"%s"}' \
"$$REDIS_ENTERPRISE_DATABASE_VERSION")
fi
create_attempt=0
until redisctl enterprise database create --data "$$database_data" --output json > /dev/null; do
create_attempt=$$((create_attempt + 1))
if [ "$$create_attempt" -ge 60 ]; then
echo "Required disposable database could not be created" >&2
exit 1
fi
echo "Database create is not ready; retrying in 5 seconds"
sleep 5
done
attempt=0
while [ "$$attempt" -lt 120 ]; do
databases=$$(redisctl enterprise database list --output json)
shards=$$(redisctl enterprise shard list --output json)
if echo "$$databases" | grep -Eq '"status"[[:space:]]*:[[:space:]]*"active"' \
&& echo "$$shards" | grep -Eq '"uid"[[:space:]]*:'; then
echo "Disposable database and shard are ready"
exit 0
fi
attempt=$$((attempt + 1))
sleep 5
done
echo "Required disposable database and shard did not become ready" >&2
exit 1
profiles:
- init