#!/usr/bin/env bash # CluPilot container entrypoint. # On a fresh checkout the bind mount carries no vendor/ or node_modules/ (both # are gitignored). The `app` container installs them once as the mapped user; # dependent daemons (reverb/queue/scheduler) wait until vendor/ exists before # starting, so they don't crash-loop. When deps already exist, this is a no-op. set -e cd /var/www/html # run a command as the image's app user (www-data == HOST_UID) with a writable HOME www() { su -s /bin/sh www-data -c "cd /var/www/html && HOME=/tmp $*"; } role="tool" if [ "${1:-}" = "supervisord" ]; then role="app" elif printf '%s ' "$@" | grep -qE 'reverb:start|queue:work|schedule:work'; then role="daemon" fi if [ "$role" = "app" ]; then [ -f vendor/autoload.php ] || www "composer install --no-interaction --prefer-dist --no-progress" [ -x node_modules/.bin/vite ] || www "npm install --no-fund --no-audit" if [ -f .env ] && ! grep -qE '^APP_KEY=.+' .env; then www "php artisan key:generate --force" || true fi elif [ "$role" = "daemon" ]; then n=0 until [ -f vendor/autoload.php ]; do n=$((n + 1)); [ "$n" -gt 150 ] && break echo "clupilot-entrypoint: waiting for vendor/ (app container installing deps) …" sleep 2 done fi exec "$@"