# Development Dockerfile with FrankenPHP FROM dunglas/frankenphp:latest-php8.4-alpine # Install system dependencies + development tools RUN apk add --no-cache \ nodejs \ npm \ git \ mysql-client \ vim \ bash \ nano # Install PHP extensions including xdebug for development RUN install-php-extensions \ pdo_mysql \ opcache \ zip \ gd \ intl \ xdebug # Install Composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer # Set working directory WORKDIR /app # Configure PHP for development RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" # Configure Xdebug (disabled by default to reduce noise) RUN echo "xdebug.mode=off" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo ";xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo ";xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ && echo ";xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini # Configure Caddy for development (simpler, no worker mode) RUN cat > /etc/caddy/Caddyfile < /start.sh <<'EOF' #!/bin/sh set -e # Create .env file if it doesn't exist if [ ! -f ".env" ]; then echo "Creating .env file from .env.example..." cp .env.example .env fi # Install dependencies if volumes are empty if [ ! -f "vendor/autoload.php" ]; then echo "Installing composer dependencies..." composer install fi # Handle node_modules with care - clean install if having issues if [ ! -f "node_modules/.bin/vite" ]; then echo "Installing npm dependencies..." # Clean any remnants first rm -rf node_modules/.* 2>/dev/null || true rm -rf /app/.npm 2>/dev/null || true # Fresh install with cache in tmp to avoid permission issues npm install --cache /tmp/.npm else echo "Node modules already installed, skipping npm install" fi # Clear Laravel caches php artisan config:clear || true php artisan cache:clear || true # Wait for database and run migrations echo "Waiting for database..." sleep 5 php artisan migrate --force || echo "Migration failed or not needed" # Run development seeder (only in dev environment) echo "Running development seeder..." php artisan db:seed --class=DevelopmentSeeder --force || echo "Seeding skipped or already done" # Generate app key if not set if [ -z "$APP_KEY" ] || [ "$APP_KEY" = "base64:YOUR_KEY_HERE" ]; then echo "Generating application key..." php artisan key:generate fi # Start Vite dev server in background npm run dev & # Start FrankenPHP exec frankenphp run --config /etc/caddy/Caddyfile EOF RUN chmod +x /start.sh # Expose ports EXPOSE 8000 5173 # Use the startup script CMD ["/start.sh"]