diff --git a/.changeset/nine-hats-warn.md b/.changeset/nine-hats-warn.md new file mode 100644 index 0000000000..fa94ad84e5 --- /dev/null +++ b/.changeset/nine-hats-warn.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": patch +--- + +Load PORT in start-database script diff --git a/cli/template/extras/start-database/mysql.sh b/cli/template/extras/start-database/mysql.sh index 3d39cc3515..2579f259ea 100755 --- a/cli/template/extras/start-database/mysql.sh +++ b/cli/template/extras/start-database/mysql.sh @@ -32,6 +32,7 @@ set -a source .env DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}') +DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}') if [ "$DB_PASSWORD" == "password" ]; then echo "You are using the default database password" @@ -49,5 +50,5 @@ docker run -d \ --name $DB_CONTAINER_NAME \ -e MYSQL_ROOT_PASSWORD="$DB_PASSWORD" \ -e MYSQL_DATABASE=project1 \ - -p 3306:3306 \ + -p "$DB_PORT":3306 \ docker.io/mysql && echo "Database container '$DB_CONTAINER_NAME' was successfully created" diff --git a/cli/template/extras/start-database/postgres.sh b/cli/template/extras/start-database/postgres.sh index cbca237a66..164e9889ac 100755 --- a/cli/template/extras/start-database/postgres.sh +++ b/cli/template/extras/start-database/postgres.sh @@ -32,6 +32,7 @@ set -a source .env DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}') +DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}') if [ "$DB_PASSWORD" = "password" ]; then echo "You are using the default database password" @@ -50,5 +51,5 @@ docker run -d \ -e POSTGRES_USER="postgres" \ -e POSTGRES_PASSWORD="$DB_PASSWORD" \ -e POSTGRES_DB=project1 \ - -p 5432:5432 \ + -p "$DB_PORT":5432 \ docker.io/postgres && echo "Database container '$DB_CONTAINER_NAME' was successfully created"