add tenant mode support in docker container:

This commit is contained in:
msukkari 2025-01-21 12:20:55 -08:00
parent 7c6adf17aa
commit 738bbaad30
2 changed files with 21 additions and 10 deletions

View file

@ -73,6 +73,8 @@ ARG SOURCEBOT_VERSION=unknown
ENV SOURCEBOT_VERSION=$SOURCEBOT_VERSION ENV SOURCEBOT_VERSION=$SOURCEBOT_VERSION
RUN echo "Sourcebot Version: $SOURCEBOT_VERSION" RUN echo "Sourcebot Version: $SOURCEBOT_VERSION"
ENV SOURCEBOT_TENANT_MODE=single
# Valid values are: debug, info, warn, error # Valid values are: debug, info, warn, error
ENV SOURCEBOT_LOG_LEVEL=info ENV SOURCEBOT_LOG_LEVEL=info

View file

@ -68,18 +68,27 @@ fi
echo "{\"version\": \"$SOURCEBOT_VERSION\", \"install_id\": \"$SOURCEBOT_INSTALL_ID\"}" > "$FIRST_RUN_FILE" echo "{\"version\": \"$SOURCEBOT_VERSION\", \"install_id\": \"$SOURCEBOT_INSTALL_ID\"}" > "$FIRST_RUN_FILE"
# Fallback to sample config if a config does not exist if [ ! -z "$SOURCEBOT_TENANT_MODE" ]; then
if echo "$CONFIG_PATH" | grep -qE '^https?://'; then echo -e "\e[34m[Info] Sourcebot tenant mode: $SOURCEBOT_TENANT_MODE\e[0m"
if ! curl --output /dev/null --silent --head --fail "$CONFIG_PATH"; then else
echo -e "\e[33m[Warning] Remote config file at '$CONFIG_PATH' not found. Falling back on sample config.\e[0m" echo -e "\e[31m[Error] SOURCEBOT_TENANT_MODE is not set.\e[0m"
CONFIG_PATH="./default-config.json" exit 1
fi
elif [ ! -f "$CONFIG_PATH" ]; then
echo -e "\e[33m[Warning] Config file at '$CONFIG_PATH' not found. Falling back on sample config.\e[0m"
CONFIG_PATH="./default-config.json"
fi fi
echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m" # If we're in single tenant mode, fallback to sample config if a config does not exist
if [ "$SOURCEBOT_TENANT_MODE" = "single" ]; then
if echo "$CONFIG_PATH" | grep -qE '^https?://'; then
if ! curl --output /dev/null --silent --head --fail "$CONFIG_PATH"; then
echo -e "\e[33m[Warning] Remote config file at '$CONFIG_PATH' not found. Falling back on sample config.\e[0m"
CONFIG_PATH="./default-config.json"
fi
elif [ ! -f "$CONFIG_PATH" ]; then
echo -e "\e[33m[Warning] Config file at '$CONFIG_PATH' not found. Falling back on sample config.\e[0m"
CONFIG_PATH="./default-config.json"
fi
echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
fi
# Update NextJs public env variables w/o requiring a rebuild. # Update NextJs public env variables w/o requiring a rebuild.
# @see: https://phase.dev/blog/nextjs-public-runtime-variables/ # @see: https://phase.dev/blog/nextjs-public-runtime-variables/