Skip to content

Commit

Permalink
feat: Load port from .env fiel in DB scripts (#1860)
Browse files Browse the repository at this point in the history
Co-authored-by: Julius Marminge <julius0216@outlook.com>
  • Loading branch information
victor-falcon and juliusmarminge committed May 7, 2024
1 parent d56de03 commit b5ced34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-hats-warn.md
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

Load PORT in start-database script
3 changes: 2 additions & 1 deletion cli/template/extras/start-database/mysql.sh
Expand Up @@ -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"
Expand All @@ -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"
3 changes: 2 additions & 1 deletion cli/template/extras/start-database/postgres.sh
Expand Up @@ -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"
Expand All @@ -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"

0 comments on commit b5ced34

Please sign in to comment.