Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to install in Docker (PHP7 not supported, PHP8 breaking changes) #787

Open
PatrykPlewaOfficial opened this issue Dec 10, 2024 · 14 comments

Comments

@PatrykPlewaOfficial
Copy link

Bug report

Title

There is a mismatch in the repository between PHP version expected in composer.json and the one installed in Dockerfile.
Running UVDesk is no longer possible on PHP7.4.

However, after selecting the Ubuntu version manually to 20.04 and replacing all PHP packages with any version 8+ it is no longer possible to install UVDesk due to breaking changes in PHP inside the migrations files.

Issue Description

In file /var/www/uvdesk/vendor/doctrine/migrations/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php

 public function __construct(?HelperSet $helperSet = null, string $helperName)

the optional parameter $helperSet comes first. Since PHP8 this is no longer possible. This causes the migrations to fail.

Preconditions

Dockerfile

FROM ubuntu:20.04

ENV GOSU_VERSION 1.11

RUN adduser uvdesk -q --disabled-password --gecos ""

# Install base supplimentary packages
RUN apt-get update && apt-get -y upgrade \
    && apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ondrej/php \
    && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
        curl \
        wget \
        git \
        unzip \
        apache2 \
        mysql-server \
        php8.2 \
        libapache2-mod-php8.2 \
        php8.2-common \
        php8.2-xml \
        php8.2-imap \
        php8.2-mysql \
        php8.2-mailparse \
        ca-certificates; \
    if ! command -v gpg; then \
		apt-get install -y --no-install-recommends gnupg2 dirmngr; \
	elif gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \
		apt-get install -y --no-install-recommends gnupg-curl; \
	fi;

COPY ./.docker/config/apache2/env /etc/apache2/envvars
COPY ./.docker/config/apache2/httpd.conf /etc/apache2/apache2.conf
COPY ./.docker/config/apache2/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY ./.docker/bash/uvdesk-entrypoint.sh /usr/local/bin/
COPY . /var/www/uvdesk/

RUN \
    # Update apache configurations
    a2enmod php8.2 rewrite; \
    chmod +x /usr/local/bin/uvdesk-entrypoint.sh; \
    # Install gosu for stepping-down from root to a non-privileged user during container startup
    dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
    wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
    && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
    # Verify gosu installation
    export GNUPGHOME="$(mktemp -d)" \
    && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
	&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
    && gpgconf --kill all \
    && chmod +x /usr/local/bin/gosu \
    && gosu nobody true; \
    \
    # Download and verify composer installer signature
    wget -O /usr/local/bin/composer.php "https://getcomposer.org/installer"; \
    actualSig="$(wget -q -O - https://composer.github.io/installer.sig)"; \
    currentSig="$(shasum -a 384 /usr/local/bin/composer.php | awk '{print $1}')"; \
    if [ "$currentSig" != "$actualSig" ]; then \
        echo "Warning: Failed to verify composer signature."; \
        exit 1; \
	fi; \
    # Install composer
    php /usr/local/bin/composer.php --quiet --filename=/usr/local/bin/composer \
    && chmod +x /usr/local/bin/composer; \
    # Assign user uvdesk the ownership of source directory
    chown -R uvdesk:uvdesk /var/www; \
    # Clean up files
    rm -rf \
        "$GNUPGHOME" \
        /var/lib/apt/lists/* \
        /usr/local/bin/gosu.asc \
        /usr/local/bin/composer.php \
        /var/www/bin \
        /var/www/html \
        /var/www/uvdesk/.docker;

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

ENTRYPOINT ["uvdesk-entrypoint.sh"]
CMD ["/bin/bash"]

Steps to reproduce

Build new image and start the container. Proceed to install in the browser.

Expected result

Successful installation

Actual result

POST wizard/xhr/load/migrations returns

<b>Deprecated</b>:  Optional parameter $helperSet declared before required parameter $helperName is implicitly treated as a required parameter in <b>/var/www/uvdesk/vendor/doctrine/migrations/lib/Doctrine/Migrations/Configuration/Connection/Loader/ConnectionHelperLoader.php</b> on line <b>25</b><br/>[]

Installation is never completed.

@papnoisanjeev
Copy link
Collaborator

@PatrykPlewaOfficial
Try with this

@PatrykPlewaOfficial
Copy link
Author

PatrykPlewaOfficial commented Dec 12, 2024

Thank you @papnoisanjeev . Unfortunately it did not resolve all the issues.

When setting up the built-in MySQL DB, there is some issue in `./docker/bash/uvdesk-entrypoint.sh.

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Error: Failed to establish a connection with mysql server (localhost)

Secondly, when omitting setting up the DB (no env variables), there is still an issue. In the web browser, the container returns 500 without any specific error message. No errors in the Docker console.

Attaching the /var/log/apache2/error.log file

[mpm_prefork:notice] [pid 30] AH00163: Apache/2.4.41 (Ubuntu) configured -- resuming normal operations
[core:notice] [pid 30] AH00094: Command line: '/usr/sbin/apache2'
[php:warn] [pid 33] [client 172.23.0.1:55308] PHP Warning:  require_once(/var/www/uvdesk/vendor/autoload_runtime.php): Failed to open stream: No such file or directory in /var/www/uvdesk/public/index.php on line 5
[php:error] [pid 33] [client 172.23.0.1:55308] PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/uvdesk/vendor/autoload_runtime.php' (include_path='.:/usr/share/php') in /var/www/uvdesk/public/index.php:5\nStack trace:\n#0 {main}\n  thrown in /var/www/uvdesk/public/index.php on line 5

@ars128
Copy link
Contributor

ars128 commented Dec 23, 2024

Hey @PatrykPlewaOfficial ,

Kindly follow this commit for the setup of the project.

Setup the project locally and then deploy on docker, and make sure that inside the container

  • apache is running
  • MySQL server is running
  • .env, var, migration, config

they have permission to write inside the container

@PatrykPlewaOfficial
Copy link
Author

Hi @ars128 ,
thanks for keeping the issue moving.

I checked out the v1.1.7_micro branch and initiated the build with the new Dockerfile.
However, this time, the container is not able to start. For some reason, the root user cannot execute the entry point shell script even though it can list the file.
image
exec /usr/local/bin/uvdesk-entrypoint.sh: no such file or directory

Additionally, I'm not sure what you mean by

Setup the project locally and then deploy on docker

What local setup do you mean apart from git checkout? If there is anything that is meant to be done on the local system then it should all be moved to the container. That's the whole purpose of Docker to not engage the host computer.

@PatrykPlewaOfficial
Copy link
Author

Ok, I found the problem. The uvdesk-entrypoint.sh on the branch has an incorrect end-of-line sequence. Please change it in the repo to LF

@PatrykPlewaOfficial
Copy link
Author

PatrykPlewaOfficial commented Dec 23, 2024

All those files that are copied by the Dockerfile have incorrect end-of-line sequence

2024-12-23 11:15:51 Setting up directory permissions for user: root
2024-12-23 11:15:51 Set permissions for /var/www/uvdesk/.env
2024-12-23 11:15:51 Set permissions for /var/www/uvdesk/config
2024-12-23 11:15:51 Set permissions for /var/www/uvdesk/public
2024-12-23 11:15:51 Created var directory
2024-12-23 11:15:51 Starting services...
2024-12-23 11:15:51 /etc/init.d/apache2: 2: /etc/apache2/envvars: 
: not found
2024-12-23 11:15:51 /etc/init.d/apache2: 4: unset: HOME
: bad variable name
2024-12-23 11:15:51 /etc/init.d/apache2: 2: /etc/apache2/envvars: 
: not found
2024-12-23 11:15:51 /etc/init.d/apache2: 4: unset: HOME
: bad variable name
2024-12-23 11:15:51 ERROR: APACHE_PID_FILE needs to be defined in /etc/apache2/envvars
2024-12-23 11:15:51 Starting MySQL setup...
2024-12-23 11:15:51 Waiting for MySQL to start... (1/30)
2024-12-23 11:15:53 Waiting for MySQL to start... (2/30)
2024-12-23 11:15:55 Waiting for MySQL to start... (3/30)
2024-12-23 11:15:57 Waiting for MySQL to start... (4/30)
2024-12-23 11:15:59 Waiting for MySQL to start... (5/30)
2024-12-23 11:16:01 Waiting for MySQL to start... (6/30)
2024-12-23 11:16:03 Waiting for MySQL to start... (7/30)
2024-12-23 11:16:05 Waiting for MySQL to start... (8/30)
2024-12-23 11:16:07 Waiting for MySQL to start... (9/30)
2024-12-23 11:16:09 Waiting for MySQL to start... (10/30)
2024-12-23 11:16:11 Waiting for MySQL to start... (11/30)
2024-12-23 11:16:13 Waiting for MySQL to start... (12/30)
2024-12-23 11:16:15 Waiting for MySQL to start... (13/30)
2024-12-23 11:16:17 Waiting for MySQL to start... (14/30)
2024-12-23 11:16:19 Waiting for MySQL to start... (15/30)
2024-12-23 11:16:21 Waiting for MySQL to start... (16/30)
2024-12-23 11:16:23 Waiting for MySQL to start... (17/30)
2024-12-23 11:16:25 Waiting for MySQL to start... (18/30)
2024-12-23 11:16:27 Waiting for MySQL to start... (19/30)
2024-12-23 11:16:29 Waiting for MySQL to start... (20/30)
2024-12-23 11:16:31 Waiting for MySQL to start... (21/30)
2024-12-23 11:16:33 Waiting for MySQL to start... (22/30)
2024-12-23 11:16:35 Waiting for MySQL to start... (23/30)
2024-12-23 11:16:37 Waiting for MySQL to start... (24/30)
2024-12-23 11:16:39 Waiting for MySQL to start... (25/30)
2024-12-23 11:16:41 Waiting for MySQL to start... (26/30)
2024-12-23 11:16:43 Waiting for MySQL to start... (27/30)
2024-12-23 11:16:45 Waiting for MySQL to start... (28/30)
2024-12-23 11:16:47 Waiting for MySQL to start... (29/30)
2024-12-23 11:16:49 Waiting for MySQL to start... (30/30)
2024-12-23 11:16:51 Failed to connect to MySQL after 30 attempts
2024-12-23 11:16:51 MySQL setup failed

@PatrykPlewaOfficial
Copy link
Author

PatrykPlewaOfficial commented Dec 23, 2024

After manually fixing the end-of-line sequence I end up with this error:
/usr/local/bin/uvdesk-entrypoint.sh: line 82: /home/root/.my.cnf: No such file or directory.

After debugging the code I understood that I should introduce an env variable for the application user.
I introduced APP_USER: uvdesk.

The last log was Creating MySQL configuration files.... After that, the attempt to run the application in the browser still returns 500.

Here is the output of /var/log/apache2/error.log:

[Mon Dec 23 10:32:05.580237 2024] [mpm_prefork:notice] [pid 34] AH00163: Apache/2.4.58 (Ubuntu) configured -- resuming normal operations
[Mon Dec 23 10:32:05.580275 2024] [core:notice] [pid 34] AH00094: Command line: '/usr/sbin/apache2'
[Mon Dec 23 10:32:51.248866 2024] [php:warn] [pid 37] [client 172.18.0.1:42410] PHP Warning:  require_once(/var/www/uvdesk/vendor/autoload_runtime.php): Failed to open stream: No such file or directory in /var/www/uvdesk/public/index.php on line 5
[Mon Dec 23 10:32:51.248930 2024] [php:error] [pid 37] [client 172.18.0.1:42410] PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/uvdesk/vendor/autoload_runtime.php' (include_path='.:/usr/share/php') in /var/www/uvdesk/public/index.php:5\nStack trace:\n#0 {main}\n  thrown in /var/www/uvdesk/public/index.php on line 5
[Mon Dec 23 10:36:14.034110 2024] [php:warn] [pid 38] [client 172.18.0.1:41492] PHP Warning:  require_once(/var/www/uvdesk/vendor/autoload_runtime.php): Failed to open stream: No such file or directory in /var/www/uvdesk/public/index.php on line 5
[Mon Dec 23 10:36:14.034237 2024] [php:error] [pid 38] [client 172.18.0.1:41492] PHP Fatal error:  Uncaught Error: Failed opening required '/var/www/uvdesk/vendor/autoload_runtime.php' (include_path='.:/usr/share/php') in /var/www/uvdesk/public/index.php:5\nStack trace:\n#0 {main}\n  thrown in /var/www/uvdesk/public/index.php on line 5

The folder vendor does not exist. That is the problem I have been reporting a few weeks back.
image

@ars128
Copy link
Contributor

ars128 commented Dec 23, 2024

The folder vendor does not exist. That is the problem I have been reporting a few weeks back.

you need to run composer create-project inside your container so all the dependent package will be downloaded inside your container for this project

@PatrykPlewaOfficial
Copy link
Author

@ars128 What is the reason behind not including this inside the Dockerfile or the setup shell script?
Building the container should create a ready-to-go environment.

@PatrykPlewaOfficial
Copy link
Author

Anyway, I ran the composer create-project and it did not succeed.

In DefinitionErrorExceptionPass.php line 49:
Cannot autowire service "Webkul\UVDesk\MailboxBundle\Console\RefreshMailboxCommand": argument "$microsoftIntegration" of method "__construct()" has type "Webkul\UVDesk\CoreFrameworkBundle\Services\MicrosoftIntegration" but this class was not found.

image

@ars128
Copy link
Contributor

ars128 commented Dec 23, 2024

FROM ubuntu:latest
LABEL maintainer="[email protected]"

ENV GOSU_VERSION=1.11

Install base supplementary packages

RUN apt-get update && apt-get -y upgrade
&& apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:ondrej/php
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install
adduser
curl
wget
git
unzip
apache2
mysql-server
php8.1
libapache2-mod-php8.1
php8.1-common
php8.1-xml
php8.1-imap
php8.1-mysql
php8.1-mailparse
ca-certificates;
if ! command -v gpg; then
apt-get install -y --no-install-recommends gnupg2 dirmngr;
elif gpg --version | grep -q '^gpg (GnuPG) 1.'; then
apt-get install -y --no-install-recommends gnupg-curl;
fi;

RUN adduser uvdesk -q --disabled-password --gecos ""

Copy Apache and entrypoint configurations

COPY ./.docker/config/apache2/env /etc/apache2/envvars
COPY ./.docker/config/apache2/httpd.conf /etc/apache2/apache2.conf
COPY ./.docker/config/apache2/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY ./.docker/bash/uvdesk-entrypoint.sh /usr/local/bin/
COPY . /var/www/uvdesk/

RUN
# Update apache configurations
a2enmod php8.1 rewrite;
chmod +x /usr/local/bin/uvdesk-entrypoint.sh;
# Install gosu for stepping-down from root to a non-privileged user during container startup
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')";
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc";
# Verify gosu installation
export GNUPGHOME="$(mktemp -d)"
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu
&& gpgconf --kill all
&& chmod +x /usr/local/bin/gosu
&& gosu nobody true;

# Download and verify composer installer signature
wget -O /usr/local/bin/composer.php "https://getcomposer.org/installer";
actualSig="$(wget -q -O - https://composer.github.io/installer.sig)";
currentSig="$(shasum -a 384 /usr/local/bin/composer.php | awk '{print $1}')";
if [ "$currentSig" != "$actualSig" ]; then
echo "Warning: Failed to verify composer signature.";
exit 1;
fi;
# Install composer
php /usr/local/bin/composer.php --quiet --filename=/usr/local/bin/composer
&& chmod +x /usr/local/bin/composer;
# Clean up files
rm -rf
"$GNUPGHOME"
/var/lib/apt/lists/*
/usr/local/bin/gosu.asc
/usr/local/bin/composer.php

Set permissions for all required files, including .env

RUN
chmod -R 775 /var/www/uvdesk/var
/var/www/uvdesk/config
/var/www/uvdesk/public
/var/www/uvdesk/migrations;
chown -R uvdesk:uvdesk /var/www;
chown -R uvdesk:uvdesk /var/www/uvdesk/.env

Install Composer dependencies

RUN
cd /var/www/uvdesk/ &&
composer install --no-dev --optimize-autoloader

Change working directory to uvdesk source

WORKDIR /var/www

ENTRYPOINT ["uvdesk-entrypoint.sh"]
CMD ["/bin/bash"]

@ars128
Copy link
Contributor

ars128 commented Dec 23, 2024

**In DefinitionErrorExceptionPass.php line 49:
Cannot autowire service "Webkul\UVDesk\MailboxBundle\Console\RefreshMailboxCommand": argument "$microsoftIntegration" of method "__construct()" has type "Webkul\UVDesk\CoreFrameworkBundle\Services\MicrosoftIntegration" but this class was not found.
**

This issue occurs because the Mailbox bundle has been updated, but the Core bundle is outdated, leading to a dependency conflict. To resolve this, update the Mailbox bundle using:

composer require uvdesk/mailbox-component:"v1.1.3"

and then clear the cache

@PatrykPlewaOfficial
Copy link
Author

PatrykPlewaOfficial commented Dec 23, 2024

I did update the mailbox-component however this time I get another error

!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#85
!!    #message: """
!!      Attempted to load class "WebProfilerBundle" from namespace "Symfony\Bundle\WebProfilerBundle".\n
!!      Did you forget a "use" statement for another namespace?
!!      """
!!    #code: 0
!!    #file: "./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php"
!!    #line: 132
!!    trace: {
!!      ./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:132 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:386 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:788 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:128 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!!      ./vendor/symfony/console/Application.php:171 { …}
!!      ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
!!      ./vendor/autoload_runtime.php:35 { …}
!!      ./bin/console:15 {
!!        › 
!!        › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!!        › 
!!        arguments: {
!!          "/var/www/uvdesk/vendor/autoload_runtime.php"
!!        }
!!      }
!!    }
!!  }
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\CoreFrameworkBundle\UVDeskCoreFrameworkBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\AutomationBundle\UVDeskAutomationBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\ExtensionFrameworkBundle\UVDeskExtensionFrameworkBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\MailboxBundle\UVDeskMailboxBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\SupportCenterBundle\UVDeskSupportCenterBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::getContainerExtension()" might add "?ExtensionInterface" as a native return type declaration in the future. Do the same in child class "Webkul\UVDesk\ApiBundle\UVDeskApiBundle" now to avoid errors or add an explicit @return annotation to suppress this message.
!!  2024-12-23T11:52:05+00:00 [critical] Uncaught Error: Class "Symfony\Bundle\WebProfilerBundle\WebProfilerBundle" not found

@ars128
Copy link
Contributor

ars128 commented Dec 23, 2024

This is realted to some symfony class which is missing while auto dump class is loaded,

You can try to setup the project again and in the composer.json file, you can set the mailbox bundle "v1.1.3" so instead of getting the latest package it will use the old one

@uvdesk uvdesk deleted a comment from ars128 Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants