Skip to content

Instantly share code, notes, and snippets.

@robertliwpe
Last active December 27, 2023 19:00
Show Gist options
  • Save robertliwpe/0b6f098f0dfb8dfa152d6cab69ffff8c to your computer and use it in GitHub Desktop.
Save robertliwpe/0b6f098f0dfb8dfa152d6cab69ffff8c to your computer and use it in GitHub Desktop.
ChromaDB Docker Instance Run Script for WordCamp Asia 2024
#!/bin/bash
# Run script for restarting ChromaDB Docker Instance
# Find the original Google Collab Notebook here: https://colab.research.google.com/drive/1PGw_QEjJFQ3vhVuSinCbWose5KNjk5wb?usp=sharing
# Initialising Variables
livechromaid=$(docker container ls | grep chromadb\/chroma | cut -d' ' -f1)
useris=$(whoami)
echo "=====> Listing running Docker Containers"
docker container ls
printf "\r\n"
echo "=====> Listing persistent folders for user: ${useris}"
tree -d /home/ec2-user/
printf "\r\n"
read -p "Please input a new unique token for your ChromaDB docker instance (Required): " newtoken
read -p "Please add your persistent user folder on the current host machine. If a new value is given it will ignore previous embeddings. If no value is given the default is: /home/${useris}/chroma-storage/" folderpath
if [ -z "${folderpath}" ]
then
echo "\r\nNo folder path detected, default will be used"
folderpath="/home/${useris}/chroma-storage/"
else
echo "\r\nConfirming folder path to be used is ${folderpath}"
folderpath=${folderpath}
fi
printf "\r\n"
echo "=====> Restarting and refreshing ChromaDB Docker Instance"
echo "Stopping..."
docker container stop ${livechromaid}
docker container rm ${livechromaid}
echo "Pulling Latest Image..."
docker pull chromadb/chroma
echo "Restarting..."
docker run -d -p 8000:8000 \
-e CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER="chromadb.auth.token.TokenConfigServerAuthCredentialsProvider" \
-e CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.token.TokenAuthServerProvider" \
-e CHROMA_SERVER_AUTH_CREDENTIALS=${newtoken} \
-e CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER="X_CHROMA_TOKEN" \
-v ${folderpath}:/chroma/chroma \
chromadb/chroma
echo "COMPLETE"
printf "\r\n"
echo "=====> Listing NEW running Docker Containers"
docker container ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment