Initialization with environment variables #66
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using Couchbase to develop a cloud-native application, I was pretty much annoyed when I realized that the official Couchbase Docker image is not configurable during startup - a feature offered by other popular database systems (e.g. MySQL).
For that purpose I quickly developed an entrypoint which uses environment variables (e.g. from docker compose files) to bootstrap a ready to use Couchbase instance. At least I will work with that.
Later I realized issue #59 and #27 which asked exactly about that. And here comes my solution.
If no environment variables are specified, nothing more will happen than with the current entrypoint. If the following environment variables are specified, the started node will create or join a cluster, with the defined admin credentials, and will create buckets during start up.
Environment Variables:
CLUSTER can be the local or a remote Couchbase instance. If it's remote, the new instance will join this remote cluster. If AUTOREBALANCE is set to true, a rebalance will be started directly after the join of the new node. BUCKETS and BUCKETSIZES are listing bucket names and their sizes, which will be created at start up time.
I have tested the new entrypoint with community version 4.5.1 several times. If the Couchbase team is interested, please further investigate some tests. (Maybe move my pull request to a branch...)