Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

deploy script fix, db connection escape password

Dane Schneider3898b1e5baef
diff --git a/app/server/db/db.go b/app/server/db/db.go
index 20dfc8d4..870a6bb6 100644
--- a/app/server/db/db.go
+++ b/app/server/db/db.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"log"
+ "net/url"
"os"
"github.com/golang-migrate/migrate/v4"
@@ -25,7 +26,9 @@ func Connect() error {
os.Getenv("DB_USER") != "" &&
os.Getenv("DB_PASSWORD") != "" &&
os.Getenv("DB_NAME") != "" {
- dbUrl = "postgres://" + os.Getenv("DB_USER") + ":" + os.Getenv("DB_PASSWORD") + "@" + os.Getenv("DB_HOST") + ":" + os.Getenv("DB_PORT") + "/" + os.Getenv("DB_NAME")
+ encodedPassword := url.QueryEscape(os.Getenv("DB_PASSWORD"))
+
+ dbUrl = "postgres://" + os.Getenv("DB_USER") + ":" + encodedPassword + "@" + os.Getenv("DB_HOST") + ":" + os.Getenv("DB_PORT") + "/" + os.Getenv("DB_NAME")
}
if dbUrl == "" {
diff --git a/infra/deploy.sh b/infra/deploy.sh
index f3a6fd00..f2e3cb0e 100755
--- a/infra/deploy.sh
+++ b/infra/deploy.sh
@@ -98,6 +98,8 @@ export IMAGE_TAG=$(git rev-parse --short HEAD)
log "IMAGE_TAG: $IMAGE_TAG"
+IS_NEW_STACK=false
+
# Function to deploy or update the CloudFormation stack using AWS CDK
deploy_or_update_stack() {
# Check if the stack exists
@@ -106,6 +108,7 @@ deploy_or_update_stack() {
if [ -z "$STACK_NAME" ]; then
# Deploy the stack if it does not exist
npx cdk deploy --require-approval never --app "npx ts-node src/main.ts" --context stackTag=$STACK_TAG "plandex-stack-$STACK_TAG"
+ IS_NEW_STACK=true
else
# Update the stack if it exists
npx cdk deploy "$STACK_NAME" --require-approval never --app "npx ts-node src/main.ts"
@@ -189,8 +192,12 @@ else
log "Skipping deploy_or_update_stack due to --image-only flag"
fi
-# Update the ECS service with the new Docker image
-log "Updating the ECS service with the new Docker image..."
-update_ecs_service
+# Update the ECS service with the new Docker image if it's not a new stack
+if [ "$IS_NEW_STACK" = false ]; then
+ log "Updating the ECS service with the new Docker image..."
+ update_ecs_service
+else
+ log "Skipping update_ecs_service for new stack"
+fi
log "Infrastructure deployed successfully"
\ No newline at end of file