All checks were successful
CI / quality-checks (push) Successful in 42s
34 lines
1.0 KiB
Bash
34 lines
1.0 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
# Copy static files to shared volume if they don't exist
|
|
# This allows Caddy to serve static files directly
|
|
if [ ! -f /shared/static/.static-files-ready ]; then
|
|
echo "Copying static files to shared volume..."
|
|
cp -r /app/src/hxbooks/static/* /shared/static/
|
|
touch /shared/static/.static-files-ready
|
|
echo "Static files copied successfully"
|
|
else
|
|
echo "Static files already present in shared volume"
|
|
fi
|
|
|
|
# Copy Caddyfile to shared volume
|
|
cp /app/Caddyfile /app/caddy/Caddyfile
|
|
|
|
# Initialize database if it doesn't exist or run migrations if it does
|
|
echo "Checking database status..."
|
|
if [ ! -f /app/instance/hxbooks.sqlite ]; then
|
|
echo "Database not found. Initializing database..."
|
|
hxbooks db init
|
|
echo "Database initialized successfully"
|
|
else
|
|
echo "Database exists. Running migrations..."
|
|
# Run Flask-Migrate migrations
|
|
flask db upgrade 2>/dev/null || {
|
|
echo "No migrations to run or migration failed. Database ready."
|
|
}
|
|
fi
|
|
|
|
# Start the application
|
|
echo "Starting HXBooks application..."
|
|
exec "$@" |