Skip to content

Commit b9d2679

Browse files
committed
fix(docker): review fixes for bash scripts
1 parent 406239f commit b9d2679

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

scripts/postgres_terminal.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ POSTGRES_USER="postgres_user"
3232
POSTGRES_PASSWORD="postgres_password"
3333
POSTGRES_DB="postgres_db"
3434

35-
while IFS='=' read -r key value; do
35+
while IFS='=' read -r key value || [ -n "$key" ]; do
3636
key=$(echo "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
3737
value=$(echo "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
3838

scripts/restore_backup.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ POSTGRES_USER="postgres_user"
118118
POSTGRES_PASSWORD="postgres_password"
119119
POSTGRES_DB="postgres_db"
120120

121-
while IFS='=' read -r key value; do
121+
while IFS='=' read -r key value || [ -n "$key" ]; do
122122
key=$(echo "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
123123
value=$(echo "$value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
124124

@@ -201,7 +201,7 @@ while true; do
201201
done
202202

203203
# 5.2 Drop the existing database
204-
output=$(docker exec -e "PGPASSWORD=$POSTGRES_PASSWORD" pneumatic-postgres dropdb -U "$POSTGRES_USER" "$POSTGRES_DB" 2>&1)
204+
output=$(docker exec -e "PGPASSWORD=$POSTGRES_PASSWORD" pneumatic-postgres dropdb -U "$POSTGRES_USER" -h "$POSTGRES_HOST" "$POSTGRES_DB" 2>&1)
205205
if [ $? -eq 0 ]; then
206206
print_info "Database successfully dropped"
207207
else
@@ -210,7 +210,7 @@ else
210210
fi
211211

212212
# 5.3 Create a new database
213-
output=$(docker exec -e "PGPASSWORD=$POSTGRES_PASSWORD" pneumatic-postgres createdb -U "$POSTGRES_USER" --owner "$POSTGRES_USER" "$POSTGRES_DB" 2>&1)
213+
output=$(docker exec -e "PGPASSWORD=$POSTGRES_PASSWORD" pneumatic-postgres createdb -U "$POSTGRES_USER" -h "$POSTGRES_HOST" --owner "$POSTGRES_USER" "$POSTGRES_DB" 2>&1)
214214
if [ $? -eq 0 ]; then
215215
print_info "Database successfully created"
216216
else
@@ -274,10 +274,11 @@ case "$COMPOSE_FILE" in
274274
output=$(docker compose -f "$PROJECT_DIR/docker-compose.src.yml" up -d 2>&1)
275275
;;
276276
4)
277-
output=$(docker compose -f "$PROJECT_DIR/frontend/docker-compose.yml" up -d 2>&1)
277+
# Compose resolves .env from the compose file's directory; pass the selected file explicitly.
278+
output=$(docker compose --env-file "$ENV_FILE" -f "$PROJECT_DIR/frontend/docker-compose.yml" up -d 2>&1)
278279
;;
279280
5)
280-
output=$(docker compose -f "$PROJECT_DIR/backend/docker-compose.yml" up -d 2>&1)
281+
output=$(docker compose --env-file "$ENV_FILE" -f "$PROJECT_DIR/backend/docker-compose.yml" up -d 2>&1)
281282
;;
282283
esac
283284

0 commit comments

Comments
 (0)