-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathdocker-entrypoint.sh
48 lines (36 loc) · 990 Bytes
/
docker-entrypoint.sh
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
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
# Function to wait for database to be ready
wait_for_db() {
echo "Waiting for database to be ready..."
# For debugging
echo "Current DATABASE_URL: $DATABASE_URL"
until PGPASSWORD=mysecretpassword pg_isready -h db -p 5432 -U root -d local
do
echo "Database connection attempt failed. Retrying in 2 seconds..."
sleep 2
done
echo "Database is ready!"
}
# Wait for database
wait_for_db
# Run database migrations
echo "Creating database ..."
if ! npx drizzle-kit generate; then
echo "Migration generation failed, but continuing..."
fi
if ! npx drizzle-kit migrate; then
echo "Migration generation failed, but continuing..."
fi
# Run database push
echo "Running database push..."
if ! npx drizzle-kit push; then
echo "Database push failed, but continuing..."
fi
# Start the application
echo "Building the application..."
exec "$@"
# Uncomment these lines if needed
npm run build
echo "Starting the application..."
node build