Files
hxbooks/docker-entrypoint.sh
Francisco Penedo Alvarez 7f4a956df3
Some checks failed
CI / quality-checks (push) Successful in 42s
Deploy / deploy (push) Failing after 58s
Add CI and deployment workflows for Gitea
2026-03-31 18:58:17 +02:00

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 "$@"