init-cbserver.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # used to start couchbase server - can't get around this as docker compose only allows you to start one command - so we have to start couchbase like the standard couchbase Dockerfile would
  3. # https://github.com/couchbase/docker/blob/master/enterprise/couchbase-server/7.2.0/Dockerfile#L88
  4. /entrypoint.sh couchbase-server &
  5. # track if setup is complete so we don't try to setup again
  6. FILE=/opt/couchbase/init/setupComplete.txt
  7. if ! [ -f "$FILE" ]; then
  8. # used to automatically create the cluster based on environment variables
  9. # https://docs.couchbase.com/server/current/cli/cbcli/couchbase-cli-cluster-init.html
  10. echo $COUCHBASE_ADMINISTRATOR_USERNAME ":" $COUCHBASE_ADMINISTRATOR_PASSWORD
  11. sleep 20s
  12. /opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1 \
  13. --cluster-username $COUCHBASE_ADMINISTRATOR_USERNAME \
  14. --cluster-password $COUCHBASE_ADMINISTRATOR_PASSWORD \
  15. --services data,index,query,fts \
  16. --cluster-ramsize $COUCHBASE_RAM_SIZE \
  17. --cluster-index-ramsize $COUCHBASE_INDEX_RAM_SIZE \
  18. --cluster-eventing-ramsize $COUCHBASE_EVENTING_RAM_SIZE \
  19. --cluster-fts-ramsize $COUCHBASE_FTS_RAM_SIZE \
  20. --index-storage-setting default
  21. sleep 2s
  22. # used to auto create the bucket based on environment variables
  23. # https://docs.couchbase.com/server/current/cli/cbcli/couchbase-cli-bucket-create.html
  24. /opt/couchbase/bin/couchbase-cli bucket-create -c localhost:8091 \
  25. --username $COUCHBASE_ADMINISTRATOR_USERNAME \
  26. --password $COUCHBASE_ADMINISTRATOR_PASSWORD \
  27. --bucket $COUCHBASE_BUCKET \
  28. --bucket-ramsize $COUCHBASE_BUCKET_RAMSIZE \
  29. --bucket-type couchbase
  30. # create file so we know that the cluster is setup and don't run the setup again
  31. touch $FILE
  32. fi
  33. # docker compose will stop the container from running unless we do this
  34. # known issue and workaround
  35. tail -f /dev/null