FROM php:8.4-fpm-alpine # Set working directory WORKDIR /var/www/html # Install system dependencies RUN apk add --no-cache \ curl \ libpng-dev \ libzip-dev \ zip \ unzip \ git \ oniguruma-dev \ sqlite \ sqlite-dev \ mysql-client \ nodejs \ npm # Install PHP extensions RUN docker-php-ext-install pdo_mysql pdo_sqlite mbstring exif pcntl bcmath gd zip # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Copy application files COPY . . # Install PHP dependencies RUN composer install --no-dev --optimize-autoloader --no-interaction # Install Node dependencies and build assets RUN npm install && npm run build && rm -rf node_modules # Set permissions RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache && \ chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache # Create SQLite database if it doesn't exist RUN touch /var/www/html/database/database.sqlite && \ chown www-data:www-data /var/www/html/database/database.sqlite && \ chmod 664 /var/www/html/database/database.sqlite # Switch to www-data user USER www-data # Expose port EXPOSE 8000 # Start the application CMD ["/bin/sh", "-c", "php artisan config:cache && php artisan route:cache && php artisan view:cache && php artisan migrate --force && php artisan serve --host=0.0.0.0 --port=8000"]