2024-10-29 03:00:23 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								#!/bin/bash
  
						 
					
						
							
								
									
										
										
										
											2025-04-29 18:04:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# 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  
						 
					
						
							
								
									
										
										
										
											2024-10-29 03:00:23 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# https://github.com/couchbase/docker/blob/master/enterprise/couchbase-server/7.2.0/Dockerfile#L88  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 18:04:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/entrypoint.sh couchbase-server & 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 03:00:23 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# track if setup is complete so we don't try to setup again  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FILE = /opt/couchbase/init/setupComplete.txt 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ! [  -f " $FILE "  ] ;  then  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # used to automatically create the cluster based on environment variables 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # https://docs.couchbase.com/server/current/cli/cbcli/couchbase-cli-cluster-init.html 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo  $COUCHBASE_ADMINISTRATOR_USERNAME  ":"   $COUCHBASE_ADMINISTRATOR_PASSWORD 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  sleep 20s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  /opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1 \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-username $COUCHBASE_ADMINISTRATOR_USERNAME  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-password $COUCHBASE_ADMINISTRATOR_PASSWORD  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --services data,index,query,fts \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-ramsize $COUCHBASE_RAM_SIZE  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-index-ramsize $COUCHBASE_INDEX_RAM_SIZE  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-eventing-ramsize $COUCHBASE_EVENTING_RAM_SIZE  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --cluster-fts-ramsize $COUCHBASE_FTS_RAM_SIZE  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --index-storage-setting default
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  sleep 2s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # used to auto create the bucket based on environment variables 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # https://docs.couchbase.com/server/current/cli/cbcli/couchbase-cli-bucket-create.html 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  /opt/couchbase/bin/couchbase-cli bucket-create -c localhost:8091 \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --username $COUCHBASE_ADMINISTRATOR_USERNAME  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --password $COUCHBASE_ADMINISTRATOR_PASSWORD  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --bucket $COUCHBASE_BUCKET  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --bucket-ramsize $COUCHBASE_BUCKET_RAMSIZE  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  --bucket-type couchbase
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 18:04:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  # create file so we know that the cluster is setup and don't run the setup again 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-29 03:00:23 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  touch $FILE 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 18:04:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								fi  
						 
					
						
							
								
									
										
										
										
											2024-10-29 03:00:23 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  # docker compose will stop the container from running unless we do this 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # known issue and workaround 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  tail -f /dev/null