FROM php:8.5-apache-trixie

# Install system dependencies and PHP GD extension (with FreeType & JPEG/PNG support)
RUN apt-get update && apt-get install -y --no-install-recommends \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j"$(nproc)" gd \
    && rm -rf /var/lib/apt/lists/*

# Use official production php.ini and configure timezone & security settings
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
    && printf "date.timezone = Europe/Berlin\nexpose_php = Off\nsession.cookie_httponly = 1\nsession.use_strict_mode = 1\n" > "$PHP_INI_DIR/conf.d/99-custom.ini"

# Enable Apache modules and harden server signature
RUN a2enmod rewrite headers expires deflate \
    && printf "ServerTokens Prod\nServerSignature Off\n" > /etc/apache2/conf-available/security-hardening.conf \
    && a2enconf security-hardening

# Copy application code
COPY --chown=www-data:www-data . /var/www/html/

EXPOSE 80
