FROM php:8.5-fpm-trixie

ARG UID=1000
ARG GID=1000
ENV USER=development
ENV GROUPNAME=$USER

RUN groupadd -g ${GID} development \
 && useradd -u ${UID} -g development -m development

# Nginx + Supervisor installieren
RUN apt-get update
RUN apt-get install -y nginx \
    supervisor \
    bash  \
    mc \
    git \
    unzip \
    libzip-dev \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    libmagickwand-dev \
    imagemagick \
    && pecl install imagick \
    && docker-php-ext-enable imagick

    #&& rm -rf /var/lib/apt/lists/* \
 RUN mkdir -p /run/nginx

RUN docker-php-ext-install mysqli pdo pdo_mysql mbstring zip exif pcntl gd

RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
 && apt-get install -y nodejs

COPY /docker/php/composer.phar /usr/bin/composer

# Arbeitsverzeichnis
WORKDIR /var/www/html

# Volumes für persistente Daten
VOLUME ["/var/www/html"]

# Ports
EXPOSE 9000

# Start PHP-FPM + Nginx
CMD ["sh", "-c", "php-fpm -D && nginx -g 'daemon off;'"]

RUN chown -R development:development /var/www

USER development

# PHP-FPM läuft automatisch auf Port 9000
EXPOSE 9000
CMD ["php-fpm"]
