FROM php:8.3-fpm RUN apt-get update && apt-get install -y --no-install-recommends \ libpng-dev libonig-dev libxml2-dev libzip-dev \ zip unzip git gosu \ netcat-traditional \ && docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip \ && apt-get clean && rm -rf /var/lib/apt/lists/* COPY --from=composer:latest /usr/bin/composer /usr/bin/composer ARG UID ARG GID # Create a new user with the specified UID and GID, reusing an existing group if GID exists RUN if getent group ${GID}; then \ group_name=$(getent group ${GID} | cut -d: -f1); \ useradd -m -u ${UID} -g ${GID} -s /bin/bash www; \ else \ groupadd -g ${GID} www && \ useradd -m -u ${UID} -g www -s /bin/bash www; \ group_name=www; \ fi # Update php-fpm to use the new user and group RUN sed -i "s/user = www-data/user = www/g" /usr/local/etc/php-fpm.d/www.conf && \ sed -i "s/group = www-data/group = $group_name/g" /usr/local/etc/php-fpm.d/www.conf COPY ./docker/entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh WORKDIR /var/www EXPOSE 9000 ENTRYPOINT ["entrypoint.sh"] CMD ["php-fpm"]