This commit is contained in:
bkellam 2025-11-05 16:29:45 -08:00
parent 4957de3b79
commit 0ca1b7e62e
2 changed files with 8 additions and 9 deletions

View file

@ -247,8 +247,9 @@ RUN chmod +x ./prefix-output.sh
COPY entrypoint.sh ./entrypoint.sh COPY entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh RUN chmod +x ./entrypoint.sh
# Default to root user, but can be overridden at runtime with --user flag # Note: for back-compat cases, we do _not_ set the USER directive here.
# No USER directive = runs as root by default # Instead, the user can be overridden at runtime with --user flag.
# USER sourcebot
EXPOSE 3000 EXPOSE 3000
ENV PORT=3000 ENV PORT=3000

View file

@ -89,13 +89,13 @@ fi
# Check if DATA_CACHE_DIR exists, if not create it # Check if DATA_CACHE_DIR exists, if not create it
if [ ! -d "$DATA_CACHE_DIR" ]; then if [ ! -d "$DATA_CACHE_DIR" ]; then
mkdir -m 0750 -p "$DATA_CACHE_DIR" mkdir -p "$DATA_CACHE_DIR"
fi fi
# Check if DATABASE_DATA_DIR exists, if not initialize it # Check if DATABASE_DATA_DIR exists, if not initialize it
if [ "$DATABASE_EMBEDDED" = "true" ] && [ ! -d "$DATABASE_DATA_DIR" ]; then if [ "$DATABASE_EMBEDDED" = "true" ] && [ ! -d "$DATABASE_DATA_DIR" ]; then
echo -e "\e[34m[Info] Initializing database at $DATABASE_DATA_DIR...\e[0m" echo -e "\e[34m[Info] Initializing database at $DATABASE_DATA_DIR...\e[0m"
mkdir -m 0750 -p $DATABASE_DATA_DIR mkdir -p $DATABASE_DATA_DIR
if [ "$IS_ROOT" = "true" ]; then if [ "$IS_ROOT" = "true" ]; then
chown -R postgres:postgres "$DATABASE_DATA_DIR" chown -R postgres:postgres "$DATABASE_DATA_DIR"
su postgres -c "initdb -D $DATABASE_DATA_DIR" su postgres -c "initdb -D $DATABASE_DATA_DIR"
@ -106,7 +106,7 @@ fi
# Create the redis data directory if it doesn't exist # Create the redis data directory if it doesn't exist
if [ "$REDIS_EMBEDDED" = "true" ] && [ ! -d "$REDIS_DATA_DIR" ]; then if [ "$REDIS_EMBEDDED" = "true" ] && [ ! -d "$REDIS_DATA_DIR" ]; then
mkdir -m 0750 -p $REDIS_DATA_DIR mkdir -p $REDIS_DATA_DIR
fi fi
if [ -z "$SOURCEBOT_ENCRYPTION_KEY" ]; then if [ -z "$SOURCEBOT_ENCRYPTION_KEY" ]; then
@ -221,7 +221,7 @@ if [ "$DATABASE_EMBEDDED" = "true" ]; then
|| createuser postgres -s || createuser postgres -s
fi fi
# Check if the database already exists, and create it if it doesn't # Check if the database already exists, and create it if it doesn't exist
EXISTING_DB=$(psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname = 'sourcebot'") EXISTING_DB=$(psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname = 'sourcebot'")
if [ "$EXISTING_DB" = "1" ]; then if [ "$EXISTING_DB" = "1" ]; then
@ -237,9 +237,7 @@ echo -e "\e[34m[Info] Running database migration...\e[0m"
DATABASE_URL="$DATABASE_URL" yarn workspace @sourcebot/db prisma:migrate:prod DATABASE_URL="$DATABASE_URL" yarn workspace @sourcebot/db prisma:migrate:prod
# Create the log directory if it doesn't exist # Create the log directory if it doesn't exist
if [ ! -d "/var/log/sourcebot" ]; then mkdir -p /var/log/sourcebot
mkdir -m 0750 -p /var/log/sourcebot
fi
# Run supervisord # Run supervisord
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf exec supervisord -c /etc/supervisor/conf.d/supervisord.conf