Skip to content

Commit 33ca2aa

Browse files
Merge pull request #7 from Mipmipp/refactor/scripts
Refactor: Scripts.
2 parents 4834e99 + 402c43a commit 33ca2aa

9 files changed

+115
-455
lines changed

data/bat-scripts/seed_local_dynamodb.bat

-14
This file was deleted.

data/bat-scripts/start_local_dynamodb.bat

-14
This file was deleted.

data/bash-scripts/start_local_api_gateway_and_lambda.sh renamed to data/scripts/start_local_api_gateway_and_lambda.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ ENDPOINT="${BASE_ENDPOINT}/restapis/${API_ID}/${STAGE}/_user_request_/items"
303303

304304
# Save the endpoint to a local environment file
305305
echo "Saving the API endpoint to the local environment file..."
306-
echo "LOCAL_API_ENDPOINT=${ENDPOINT}" >> .local.env
306+
echo "LOCAL_API_ENDPOINT=${ENDPOINT}" > .local.env
307307
echo ${GENERIC_SUCCESS_LOG}
308308

309309
# Output the API endpoint

data/scripts/wait-for-docker.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Container name must be consistent with the name defined in the docker-compose.yaml
4+
CONTAINER_NAME="localstack-ts-api-gateway-lambda-dynamodb-crud"
5+
TIMEOUT=30 # Maximum wait time in seconds
6+
INTERVAL=2 # Interval between checks in seconds
7+
8+
# Loop to check the health status of the container
9+
for (( i=0; i<$TIMEOUT; i+=$INTERVAL )); do
10+
# Check if the container is healthy
11+
if [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_NAME 2>/dev/null)" == "healthy" ]; then
12+
echo "$CONTAINER_NAME is ready."
13+
exit 0
14+
fi
15+
echo "Waiting for $CONTAINER_NAME to be ready..."
16+
sleep $INTERVAL # Wait for the specified interval before checking again
17+
done
18+
19+
echo "$CONTAINER_NAME is not ready after $TIMEOUT seconds."
20+
exit 1 # Exit with a failure status

docker-compose.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ services:
1313
volumes:
1414
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
1515
- "/var/run/docker.sock:/var/run/docker.sock"
16+
healthcheck:
17+
test: ["CMD", "curl", "-f", "http://localhost:4566/_localstack/health"]
18+
interval: 10s
19+
timeout: 5s
20+
retries: 5

0 commit comments

Comments
 (0)