-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03-run-docker-container.sh
More file actions
executable file
·38 lines (33 loc) · 1.06 KB
/
Copy path03-run-docker-container.sh
File metadata and controls
executable file
·38 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Variables
source ./00-variables.sh
# Retrieve the PostgreSQL server FQDN
PG_FQDN_FULL=$(az postgres flexible-server show \
--name "$PG_SERVER_NAME" \
--resource-group "$RESOURCE_GROUP_NAME" \
--query "fullyQualifiedDomainName" \
--output tsv)
if [ -z "$PG_FQDN_FULL" ]; then
echo "Failed to retrieve PostgreSQL server FQDN. Run 01-deploy-resources.sh first."
exit 1
fi
# Split host:port (LocalStack emulator embeds the dynamic TCP-proxy port in fullyQualifiedDomainName;
# real Azure returns just the bare host).
PG_FQDN="${PG_FQDN_FULL%%:*}"
if [[ "$PG_FQDN_FULL" == *:* ]]; then
PG_PORT="${PG_FQDN_FULL##*:}"
fi
# --network=host so endpoints like *.localhost.localstack.cloud resolve to the
# host's loopback (where LocalStack is listening), not the container's.
docker run -it \
--rm \
--network=host \
-e PORT=$PORT \
-e PG_HOST="$PG_FQDN" \
-e PG_PORT="$PG_PORT" \
-e PG_DATABASE="$PG_DATABASE_NAME" \
-e PG_USER="$PG_USER_NAME" \
-e PG_PASSWORD="$PG_USER_PASSWORD" \
-e LOGIN_NAME="$LOGIN_NAME" \
--name "$IMAGE_NAME" \
"$IMAGE_NAME:$IMAGE_TAG"