FROM php:8.4-apache

# 타임존 (옵션)
RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
    && echo Asia/Seoul > /etc/timezone

# mod_rewrite 활성화
RUN a2enmod rewrite

# intl, pdo_mysql 설치 (이미 있으면 그대로 두셔도 됨)
RUN apt-get update && apt-get install -y libicu-dev \
    && docker-php-ext-install intl pdo pdo_mysql

# DocumentRoot 를 CI4 public 으로 변경
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public

# 기본 vhost 의 DocumentRoot 만 변경
RUN sed -ri -e 's!DocumentRoot /var/www/html!DocumentRoot ${APACHE_DOCUMENT_ROOT}!g' \
    /etc/apache2/sites-available/000-default.conf

# CI4 public 디렉터리에 .htaccess 허용 + 접근 허용
RUN printf "<Directory /var/www/html/public>\n\
    AllowOverride All\n\
    Require all granted\n\
</Directory>\n" > /etc/apache2/conf-available/ci4.conf \
    && a2enconf ci4

WORKDIR /var/www/html
