content: FROM php:8.4-fpm-alpine
  
  ARG UID
  ARG GID
  
  ENV UID=${UID}
  ENV GID=${GID}
  
  RUN mkdir -p /var/www/html
  
  WORKDIR /var/www/html
  
  COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
  
  RUN delgroup dialout
  
  RUN addgroup -g ${GID} --system laravel
  RUN adduser -G laravel --system -D -s /bin/sh -u ${UID} laravel
  
  RUN sed -i "s/user = www-data/user = laravel/g" /usr/local/etc/php-fpm.d/www.conf
  RUN sed -i "s/group = www-data/group = laravel/g" /usr/local/etc/php-fpm.d/www.conf
  RUN echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
  
  RUN apk add --no-cache \
      curl \
      libxml2-dev \
      php-soap \
      libzip-dev \
      unzip \
      zip \
      libpng \
      libpng-dev \
      jpeg-dev \
      oniguruma-dev \
      curl-dev \
      freetype-dev \
      libpq-dev \
      bash \
      supervisor \
      postgresql-client \
      linux-headers
  
  RUN docker-php-ext-install pgsql pdo pdo_pgsql mbstring exif zip soap bcmath curl zip opcache sockets posix
  
  RUN docker-php-ext-configure pcntl --enable-pcntl \
      && docker-php-ext-install pcntl
  
  RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg \
      && docker-php-ext-install -j$(nproc) gd
  
  RUN mkdir -p /usr/src/php/ext/redis \
      && curl -L https://github.com/phpredis/phpredis/archive/6.1.0.tar.gz | tar xvz -C /usr/src/php/ext/redis --strip 1 \
      && echo 'redis' >> /usr/src/php-available-exts \
      && docker-php-ext-install redis
  
  USER laravel
  
  CMD ["php-fpm", "-y", "/usr/local/etc/php-fpm.conf", "-R"]
  