2024-08-31 01:36:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
|
|
2024-09-28 06:38:32 +00:00
|
|
|
# Fallback to sample config if a config does not exist
|
|
|
|
|
if [ ! -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="./sample-config.json"
|
2024-09-05 20:00:27 +00:00
|
|
|
fi
|
|
|
|
|
|
2024-09-28 06:38:32 +00:00
|
|
|
echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
|
|
|
|
|
|
2024-08-31 01:36:53 +00:00
|
|
|
# Check if GITHUB_TOKEN is set
|
|
|
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
|
|
|
echo "$GITHUB_TOKEN" > "$HOME/.github-token"
|
|
|
|
|
chmod 600 "$HOME/.github-token"
|
2024-09-05 04:12:56 +00:00
|
|
|
|
2024-08-31 01:36:53 +00:00
|
|
|
# Configure Git with the provided GITHUB_TOKEN
|
2024-09-05 04:12:56 +00:00
|
|
|
echo "machine github.com
|
|
|
|
|
login oauth
|
|
|
|
|
password ${GITHUB_TOKEN}" >> "$HOME/.netrc"
|
|
|
|
|
chmod 600 "$HOME/.netrc"
|
2024-08-31 01:36:53 +00:00
|
|
|
else
|
2024-09-28 06:38:32 +00:00
|
|
|
echo -e "\e[34m[Info] Private GitHub repositories will not be indexed since GITHUB_TOKEN was not set.\e[0m"
|
2024-08-31 01:36:53 +00:00
|
|
|
fi
|
|
|
|
|
|
2024-09-04 20:55:47 +00:00
|
|
|
# Check if GITLAB_TOKEN is set
|
|
|
|
|
if [ -n "$GITLAB_TOKEN" ]; then
|
|
|
|
|
echo "$GITLAB_TOKEN" > "$HOME/.gitlab-token"
|
|
|
|
|
chmod 600 "$HOME/.gitlab-token"
|
2024-09-04 21:23:50 +00:00
|
|
|
|
|
|
|
|
# Configure Git with the provided GITLAB_TOKEN
|
|
|
|
|
echo "machine gitlab.com
|
|
|
|
|
login oauth
|
2024-09-05 04:12:56 +00:00
|
|
|
password ${GITLAB_TOKEN}" >> "$HOME/.netrc"
|
2024-09-04 21:23:50 +00:00
|
|
|
chmod 600 "$HOME/.netrc"
|
2024-09-04 20:55:47 +00:00
|
|
|
else
|
2024-09-28 06:38:32 +00:00
|
|
|
echo -e "\e[34m[Info] GitLab repositories will not be indexed since GITLAB_TOKEN was not set.\e[0m"
|
2024-09-04 20:55:47 +00:00
|
|
|
fi
|
|
|
|
|
|
2024-09-17 04:37:34 +00:00
|
|
|
# Update nextjs public env variables w/o requiring a rebuild.
|
|
|
|
|
# @see: https://phase.dev/blog/nextjs-public-runtime-variables/
|
|
|
|
|
|
|
|
|
|
# Infer NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED if it is not set
|
|
|
|
|
if [ -z "$NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED" ] && [ ! -z "$SOURCEBOT_TELEMETRY_DISABLED" ]; then
|
|
|
|
|
export NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED="$SOURCEBOT_TELEMETRY_DISABLED"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
find /app/public /app/.next -type f -name "*.js" |
|
|
|
|
|
while read file; do
|
|
|
|
|
sed -i "s|BAKED_NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED|${NEXT_PUBLIC_SOURCEBOT_TELEMETRY_DISABLED}|g" "$file"
|
|
|
|
|
done
|
|
|
|
|
|
2024-09-05 20:00:27 +00:00
|
|
|
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf
|