fedi-feed-router/docker/entrypoint.sh

42 lines
No EOL
1.2 KiB
Bash

#!/bin/sh
# Exit on any error
set -e
# Check required Lemmy environment variables
if [ -z "$LEMMY_INSTANCE" ] || [ -z "$LEMMY_USERNAME" ] || [ -z "$LEMMY_PASSWORD" ] || [ -z "$LEMMY_COMMUNITY" ]; then
echo "ERROR: Missing required Lemmy configuration variables:"
echo " LEMMY_INSTANCE=${LEMMY_INSTANCE:-'(not set)'}"
echo " LEMMY_USERNAME=${LEMMY_USERNAME:-'(not set)'}"
echo " LEMMY_PASSWORD=${LEMMY_PASSWORD:-'(not set)'}"
echo " LEMMY_COMMUNITY=${LEMMY_COMMUNITY:-'(not set)'}"
echo "Please set all required environment variables before starting the application."
exit 1
fi
# Wait for database to be ready
until php artisan tinker --execute="DB::connection()->getPdo();" > /dev/null 2>&1; do
echo "Waiting for database connection..."
sleep 2
done
# Run migrations on first start (web container only)
if [ "$1" = "web" ]; then
php artisan migrate --force
fi
# Execute the command based on the argument
case "$1" in
"web")
echo "Starting web server..."
exec php artisan serve --host=0.0.0.0 --port=8000
;;
"queue")
echo "Starting queue worker..."
exec php artisan queue:work --tries=3
;;
*)
echo "Usage: $0 {web|queue}"
exit 1
;;
esac