FROM php:8.5.12-apache

# Enable Apache modules
RUN a2enmod rewrite headers

# Copy website files
COPY . /var/www/html/

# Set working directory
WORKDIR /var/www/html

# Fix ownership and permissions
RUN chown -R www-data:www-data /var/www/html \
    && find /var/www/html -type d -exec chmod 755 {} \; \
    && find /var/www/html -type f -exec chmod 644 {} \;

# Configure Apache to allow .htaccess
RUN printf '<Directory /var/www/html>\n\
    Options FollowSymLinks\n\
    AllowOverride All\n\
    Require all granted\n\
</Directory>\n' >> /etc/apache2/apache2.conf

EXPOSE 80

CMD ["apache2-foreground"]

