FROM php:8.2-apache

# Modülleri aktif et
RUN a2enmod rewrite expires deflate headers

# Apache Site Konfigürasyonunu doğrudan güncelle (CSS ve JS zorlaması ile)
RUN echo '<VirtualHost *:80>\n\
    DocumentRoot /var/www/html\n\
    <Directory /var/www/html>\n\
        AllowOverride All\n\
        Require all granted\n\
    </Directory>\n\
    # Gzip ve Cache ayarları\n\
    <IfModule mod_expires.c>\n\
        ExpiresActive On\n\
        ExpiresDefault "access plus 1 month"\n\
        ExpiresByType image/jpg "access plus 1 year"\n\
        ExpiresByType image/jpeg "access plus 1 year"\n\
        ExpiresByType image/png "access plus 1 year"\n\
        ExpiresByType image/webp "access plus 1 year"\n\
        ExpiresByType font/woff2 "access plus 1 year"\n\
        ExpiresByType text/css "access plus 1 year"\n\
        ExpiresByType application/javascript "access plus 1 year"\n\
    </IfModule>\n\
    <IfModule mod_headers.c>\n\
        <FilesMatch "\\.(css|js|jpg|jpeg|png|gif|webp|woff2|svg)$">\n\
            Header set Cache-Control "max-age=31536000, public, immutable"\n\
        </FilesMatch>\n\
    </IfModule>\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf

# Proje dosyalarını kopyala
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html/

WORKDIR /var/www/html
EXPOSE 80
