diff --git a/docker-compose.yml b/docker-compose.yml index 2f5ee36..c013c15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,4 +14,4 @@ services: POSTGRES_PASSWORD: PO24VjITwGgk POSTGRES_DB: adventurelog ports: - - "5432:5432" + - "5432:5432" \ No newline at end of file diff --git a/startup.sh b/startup.sh index 7c9c866..fbc29bb 100644 --- a/startup.sh +++ b/startup.sh @@ -1,8 +1,24 @@ #!/bin/sh +# Function to check if the database is ready +wait_for_db() { + echo "Waiting for the database to start up..." + while ! nc -z db 5432; do + sleep 1 + done + echo "Database is now available." +} + # Start your application here # Example: node build/index.js -# print message +# Print message echo "Starting AdventureLog" + +# Wait for the database to start up +wait_for_db + +# Run database migration npm run migrate + +# Start the application node build/index.js