FROM php:8.2-apache

# Install mysqli extension for PHP
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

# Enable Apache rewrite module
RUN a2enmod rewrite

# Copy project files into container
COPY . /var/www/html/

# Remove dangling symlink if exists, and create a real uploads directory
RUN rm -f /var/www/html/uploads && mkdir -p /var/www/html/uploads

# Set ownership and permissions for uploads directory
RUN chown -R www-data:www-data /var/www/html && chmod -R 775 /var/www/html/uploads

EXPOSE 80
