Last active
August 9, 2023 12:36
-
-
Save alexpetrean80/55e36b8f6c7169c2f8c03342c410916d to your computer and use it in GitHub Desktop.
A script that waits for a file to exist in a docker container with a timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
FILE_PATH=$1 | |
CONTAINER=$2 | |
TIMEOUT=$3 | |
start_time=$(date +%s) | |
while true; do | |
elapsed_time=$(($(date +%s) - start_time)) | |
if [ $elapsed_time -gt $TIMEOUT ]; then | |
echo "Timeout reached" | |
exit 1 | |
fi | |
docker compose exec "$CONTAINER" [ -f "$FILE_PATH" ] && break | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment