# Use an official PHP image with PHP 8 and Composer pre-installed
FROM php:8-fpm

# Set working directory to /var/www
WORKDIR /var/www

# Install required extensions
RUN docker-php-ext-install pdo pdo_mysql

# Install Composer globally
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy Laravel application code into the container
COPY . /var/www

# Install application dependencies
RUN composer install

# Set appropriate permissions
RUN chown -R www-data:www-data /var/www/storage
RUN chown -R www-data:www-data /var/www/bootstrap/cache

# Expose the port PHP-FPM listens on
EXPOSE 9000

# Start PHP-FPM
CMD ["php-fpm"]
