2024-04-02 14:41:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-04-02 19:33:26 +00:00
|
|
|
# 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."
|
|
|
|
}
|
|
|
|
|
2024-04-11 22:58:54 +00:00
|
|
|
# Function to run SQL scripts
|
|
|
|
run_sql_scripts() {
|
|
|
|
echo "Running SQL scripts..."
|
|
|
|
|
|
|
|
# Define the path to your SQL scripts
|
|
|
|
SQL_SCRIPTS_PATH="/sql" # Replace with the path to your SQL scripts
|
|
|
|
|
|
|
|
# Run each SQL script in the directory using the DATABASE_URL
|
|
|
|
for sql_script in "$SQL_SCRIPTS_PATH"/*.sql; do
|
|
|
|
echo "Running script: $sql_script"
|
|
|
|
psql "$DATABASE_URL" -f "$sql_script"
|
|
|
|
done
|
|
|
|
echo "Finished running SQL scripts."
|
|
|
|
}
|
|
|
|
|
2024-04-18 23:00:35 +00:00
|
|
|
|
2024-04-02 14:41:07 +00:00
|
|
|
# Start your application here
|
2024-04-02 19:33:26 +00:00
|
|
|
# Print message
|
2024-04-02 18:04:27 +00:00
|
|
|
echo "Starting AdventureLog"
|
2024-04-02 19:33:26 +00:00
|
|
|
|
|
|
|
# Wait for the database to start up
|
2024-04-18 01:24:00 +00:00
|
|
|
if [ -z "$SKIP_DB_WAIT" ] || [ "$SKIP_DB_WAIT" = "false" ]; then
|
2024-04-18 01:15:52 +00:00
|
|
|
wait_for_db
|
|
|
|
fi
|
2024-04-02 19:33:26 +00:00
|
|
|
|
2024-04-18 23:00:35 +00:00
|
|
|
# Wait for the database to start up
|
2024-04-18 23:48:07 +00:00
|
|
|
|
2024-04-18 23:00:35 +00:00
|
|
|
|
2024-04-10 01:31:10 +00:00
|
|
|
# generate the schema
|
2024-04-12 14:26:30 +00:00
|
|
|
# npm run generate
|
2024-04-10 01:31:10 +00:00
|
|
|
|
2024-04-02 19:33:26 +00:00
|
|
|
# Run database migration
|
2024-04-02 14:41:07 +00:00
|
|
|
npm run migrate
|
2024-04-02 19:33:26 +00:00
|
|
|
|
2024-04-11 22:58:54 +00:00
|
|
|
# Run SQL scripts
|
2024-04-26 22:43:13 +00:00
|
|
|
# run_sql_scripts
|
2024-04-11 22:58:54 +00:00
|
|
|
|
|
|
|
echo "The origin to be set is: $ORIGIN"
|
2024-04-02 19:33:26 +00:00
|
|
|
# Start the application
|
2024-04-10 13:30:54 +00:00
|
|
|
ORIGIN=$ORIGIN node build
|