FROM php:7.4-apache

# Install system dependencies for PHP extensions
RUN apt-get update && apt-get install -y \
    socat \
    libc-client-dev \
    libkrb5-dev \
    libsodium-dev \
    libsqlite3-dev \
    libxslt-dev \
    libcurl4-openssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Configure and install PHP extensions
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
    && docker-php-ext-install -j$(nproc) \
    mysqli \
    pdo_mysql \
    sodium \
    pdo_sqlite \
    xsl \
    fileinfo \
    imap \
    mbstring \
    gettext \
    curl \
    sockets

# Enable opcache
RUN docker-php-ext-enable opcache

# Copy your application source code into the container's web root
COPY src/ /var/www/html/

# Copy and set permissions for the entrypoint script
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh

# Set the entrypoint to our new script
ENTRYPOINT ["entrypoint.sh"]
