diff --git a/docker-compose.yaml b/docker-compose.yaml index f2b90efbd..7fb733c4c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,12 +26,7 @@ services: context: . dockerfile: Dockerfile args: - NEXT_PUBLIC_WEBAPP_URL: ${NEXT_PUBLIC_WEBAPP_URL} - NEXT_PUBLIC_LICENSE_CONSENT: ${NEXT_PUBLIC_LICENSE_CONSENT} - CALCOM_TELEMETRY_DISABLED: ${CALCOM_TELEMETRY_DISABLED} - NEXTAUTH_SECRET: ${NEXTAUTH_SECRET} - CALENDSO_ENCRYPTION_KEY: ${CALENDSO_ENCRYPTION_KEY} - DATABASE_URL: ${DATABASE_URL} + - DATABASE_URL network: stack restart: always networks: diff --git a/scripts/replace-placeholder.sh b/scripts/replace-placeholder.sh index 57dbabbbc..cabfdeffc 100755 --- a/scripts/replace-placeholder.sh +++ b/scripts/replace-placeholder.sh @@ -1,16 +1,22 @@ -FROM=$1 -TO=$2 - -if [ "${FROM}" = "${TO}" ]; then - echo "Nothing to replace, the value is already set to ${TO}." - - exit 0 -fi - -# Only peform action if $FROM and $TO are different. -echo "Replacing all statically built instances of $FROM with $TO." - -find apps/web/.next/ apps/web/public -type f | -while read file; do - sed -i "s|$FROM|$TO|g" "$file" -done +#!/bin/sh + +# List of variables to replace +VARIABLES="NEXT_PUBLIC_WEBAPP_URL NEXT_PUBLIC_LICENSE_CONSENT CALCOM_TELEMETRY_DISABLED NEXTAUTH_SECRET CALENDSO_ENCRYPTION_KEY DATABASE_URL" + +for VAR in $VARIABLES; do + # Retrieve the current value of the variable + TO_VALUE=$(eval echo \$$VAR) + + # Only proceed if the variable is set and not empty + if [ ! -z "$TO_VALUE" ]; then + FROM_PLACEHOLDER="PLACEHOLDER_${VAR}" + echo "Replacing $FROM_PLACEHOLDER with $TO_VALUE" + + find apps/web/.next/ apps/web/public -type f | + while read file; do + sed -i "s|$FROM_PLACEHOLDER|$TO_VALUE|g" "$file" + done + else + echo "Variable $VAR is not set. Skipping replacement for $VAR." + fi +done \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh index d92bf2e09..8182a4104 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -3,7 +3,7 @@ set -x # Replace the statically built BUILT_NEXT_PUBLIC_WEBAPP_URL with run-time NEXT_PUBLIC_WEBAPP_URL # NOTE: if these values are the same, this will be skipped. -scripts/replace-placeholder.sh "$BUILT_NEXT_PUBLIC_WEBAPP_URL" "$NEXT_PUBLIC_WEBAPP_URL" +scripts/replace-placeholder.sh scripts/wait-for-it.sh ${DATABASE_HOST} -- echo "database is up" npx prisma migrate deploy --schema /calcom/packages/prisma/schema.prisma