uvdesk / community-skeleton

UVdesk Opensource Community Helpdesk Project built for all to make a Full Ticketing Support System along with many more other features.
https://www.uvdesk.com
MIT License
7.15k stars 449 forks source link

System requirements check says missing mailparse but PHP shows it loaded #696

Closed sethicis closed 9 months ago

sethicis commented 9 months ago

The Issue

I'm working on a Docker image for PHP8-alpine with apache2 and uvdesk/community-skeleton. I got the image to build and uvdesk setup to startup, but when uvdesk does its requirements check it always fails on the mailparse extension verification. (See below)

Screenshot 2023-09-14 at 6 07 13 PM

I verified the mailparse extension is loaded with the below methods:

php -i | grep -i mailparse
# output
/usr/local/etc/php/conf.d/docker-php-ext-mailparse.ini,
mailparse
mailparse support => enabled
mailparse.def_charset => us-ascii => us-ascii
php -r 'var_dump(get_loaded_extensions());' | grep -i mailparse
# output
  string(9) "mailparse"

I'm kind of at a loss as to why the uvdesk requirements check is saying the mailparse extension is missing. Any assistance that you can provide would be much appreciated.

My Dockerfile

FROM php:8.0-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

ENV APACHE_LOG_DIR=/var/www/logs

RUN apk add --no-cache apache2-ctl php8-ctype php8-zip \
    php8-curl php8-intl php8-gd php8-dom php8-iconv php8-pdo php8-xml \
    php8-bz2 php8-calendar php8-exif php8-fileinfo php8-json php8-mysqli \
    php8-xsl php8-mbstring php8-pdo_mysql php8-posix \
    php8-tokenizer php8-xmlwriter php8-xmlreader php8-phar php8-soap php8-fpm php8-gmp php8-bcmath php8-apcu \
    php8-redis php8-imap php8-xdebug apache2 wget mysql-client php8-apache2 && \
    install-php-extensions mailparse imagick && \
    adduser uvdesk -Dg "" &> /dev/null && \
    cd /var/www && \
    wget https://raw.githubusercontent.com/composer/getcomposer.org/033d349db34fa132d0ea865e06ad3d224b7dbbb5/web/installer -O - -q | php -- --quiet && \
    ./composer.phar clear-cache && \
    COMPOSER_MEMORY_LIMIT=1G ./composer.phar create-project uvdesk/community-skeleton uvdesk && \
    chmod 777 -R /var/www/uvdesk/.env && \
    chmod 777 -R /var/www/uvdesk/config && \
    chmod 777 -R /var/www/uvdesk/var && \
    cd /var/www/uvdesk && \
    cp ./.docker/config/apache2/env /etc/apache2/envvars && \
    cp ./.docker/config/apache2/httpd.conf /etc/apache2/apache2.conf && \
    mkdir -p /etc/apache2/conf.d && \
    chown -R uvdesk:uvdesk /var/www && \
    apachectl restart && \
    php -d memory_limit=1G bin/console c:c; \
    # Clean up files
    rm -rf \
    /usr/local/bin/gosu.asc \
    /usr/local/bin/composer.php \
    /var/www/bin \
    /var/www/html \
    /var/www/uvdesk/.docker \
    /usr/local/bin/install-php-extensions;

COPY --chown=root:root configs/000-uvdesk.conf /etc/apache2/conf.d/
COPY --chmod=755 entrypoint.sh /usr/local/bin/entrypoint.sh

# Change working directory to uvdesk source
WORKDIR /var/www

ENTRYPOINT ["entrypoint.sh"]
CMD ["sh"]
sethicis commented 9 months ago

Fyi, @tyancolte

komal-sh-27 commented 9 months ago

@sethicis

Once you can installed the mailparse extension with version defined like this:

php-mailparse php8-mailparse

Kind Respects, Uvdesk Team

sethicis commented 9 months ago

@Komal-sharma-2712 , those packages don't exist in alpine. You can see a full list of what's available in alpine here

There is a php8-pecl-mailparse, which I originally used, but that doesn't get linked properly, which is why I switched to using install-php-extensions mailparse imagick.

install-php-extensions comes from mlocati/php-extension-installer which is a tool built to assist in adding php extensions to docker images. You can read more about it here.

sethicis commented 9 months ago

@Komal-sharma-2712 , how does the system requirements check for mailparse work? Is it not just using get_loaded_extensions in PHP?

sethicis commented 9 months ago

Ok, I found where it does the system requirement checks. https://github.com/uvdesk/community-skeleton/blob/master/src/Controller/ConfigureHelpdesk.php#L79

It uses extension_loaded to check, so I ran the same logic in the cli:

php -r 'var_dump(extension_loaded("mailparse"));'
bool(true)
sethicis commented 9 months ago

Ok, I've got this figured out. The issue has to do with how the base image is created. In my Dockerfile I install fpm and php packages via apk, but the php8 I'm running is baked into the image itself.

The baked in version of PHP is compiled with a different extensions directory and scan directory set. This is why when I check php-cli everything seems to be present, but the php-fpm can't find mailparser.

install-php-extensions installs extensions to the location that the base image version of php8 (php-cli), expects, so it reports everything is ok. While php-fpm, installed via apk is looking in a completely different place for its configs and extensions, so it reports things are missing.

The solution I'm working on is changing my image to be based on php8.0:fpm-alpine, so that both php-cli and fpm have the same compiled configuration. Then I'm going to use install-php-extensions to install any missing extensions.

Thank you all for your help. This is no longer an issue with uvdesk, just my own Docker image work -- closing this issue.