FROM php:8.3-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
    pkg-config \
    libzip-dev \
    libpng-dev \
    libjpeg-dev \
    libonig-dev \
    libxml2-dev \
    libxslt-dev \
    libmagickwand-dev \
    libreadline-dev \
    libsodium-dev \
    libc-client-dev \
    libkrb5-dev \
    unzip \
    git \
    curl \
    zip \
    build-essential \
    autoconf \
    libtool \
    libsqlite3-dev \
    mariadb-client \
    libpq-dev \
 && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
 && docker-php-ext-install \
        dom \
        xml \
        xsl \
        bcmath \
        calendar \
        exif \
        ftp \
        gd \
        gettext \
        mbstring \
        pcntl \
        pdo_mysql \
        pdo_sqlite \
        pdo_pgsql \
        pgsql \
        posix \
        shmop \
        simplexml \
        sockets \
        sodium \
        zip \
        imap \
        xmlwriter \
 && pecl install imagick \
 && docker-php-ext-enable imagick \
 && apt-get purge -y --auto-remove \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html
# Install Laravel 10.10 secara langsung (opsional jika project belum ada)
# RUN composer create-project laravel/laravel:^10 /var/www/html

# Set permission
#RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache

EXPOSE 9000
#CMD ["php-fpm"]
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
