jgeusebroek / docker-spotweb

A docker image running ubuntu/20.04 Linux and Spotweb
47 stars 27 forks source link

docker pull arm64 image gives php error #54

Closed hlugt closed 1 year ago

hlugt commented 1 year ago

Hi,

Thanks for your containers. But latest images for arm pulled (either armv7/armv8/arm64) architecture give error: "/var/www/spotweb/vendor/bin/phpunit: file name too long" The amd64 version ~error~ pulls ok...

So I guess this must be arm specific. Just a wild guess: maybe on build for arm missing -no-dev ([spotweb issue #](error: failed to symlink 'vendor/bin/phpunit': File name too long #749)?

Would really like to continue using your container but on a arm sbc... Could you take a look?

docker.io/jgeusebroek/spotweb@sha256:9d0d53f326fca428eab0577412669a71bad64914e8754dea41d4671ece4591bd: Pulling from jgeusebroek/spotweb
cfbc8b467b3e: Pull complete
2044959967d2: Pull complete
c572e3b3e330: Extracting [==================================================>]  11.73MB/11.73MB
738eaf8efc38: Download complete
6b1ab3816dfa: Download complete
ab8b5b98b0c6: Download complete
3e93e4abe3e1: Download complete
0b4bf5045edd: Download complete
1256f34c18ff: Download complete
failed to register layer: Error processing tar file(exit status 1): symlink #!/usr/bin/env php
<?php

/**
 * Proxy PHP file generated by Composer
 *
 * This file includes the referenced bin path (../phpunit/phpunit/phpunit)
 * using a stream wrapper to prevent the shebang from being output on PHP<8
 *
 * @generated
 */

namespace Composer;

$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
$GLOBALS['__PHPUNIT_ISOLATION_EXCLUDE_LIST'] = $GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST'] = array(realpath(__DIR__ . '/..'.'/phpunit/phpunit/phpunit'));

if (PHP_VERSION_ID < 80000) {
    if (!class_exists('Composer\BinProxyWrapper')) {
        /**
         * @internal
         */
        final class BinProxyWrapper
        {
            private $handle;
            private $position;
            private $realpath;

            public function stream_open($path, $mode, $options, &$opened_path)
            {
                // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
                $opened_path = substr($path, 17);
                $this->realpath = realpath($opened_path) ?: $opened_path;
                $opened_path = 'phpvfscomposer://'.$this->realpath;
                $this->handle = fopen($this->realpath, $mode);
                $this->position = 0;

                return (bool) $this->handle;
            }

            public function stream_read($count)
            {
                $data = fread($this->handle, $count);

                if ($this->position === 0) {
                    $data = preg_replace('{^#!.*\r?\n}', '', $data);
                }
                $data = str_replace('__DIR__', var_export(dirname($this->realpath), true), $data);
                $data = str_replace('__FILE__', var_export($this->realpath, true), $data);

                $this->position += strlen($data);

                return $data;
            }

            public function stream_cast($castAs)
            {
                return $this->handle;
            }

            public function stream_close()
            {
                fclose($this->handle);
            }

            public function stream_lock($operation)
            {
                return $operation ? flock($this->handle, $operation) : true;
            }

            public function stream_seek($offset, $whence)
            {
                if (0 === fseek($this->handle, $offset, $whence)) {
                    $this->position = ftell($this->handle);
                    return true;
                }

                return false;
            }

            public function stream_tell()
            {
                return $this->position;
            }

            public function stream_eof()
            {
                return feof($this->handle);
            }

            public function stream_stat()
            {
                return array();
            }

            public function stream_set_option($option, $arg1, $arg2)
            {
                return true;
            }

            public function url_stat($path, $flags)
            {
                $path = substr($path, 17);
                if (file_exists($path)) {
                    return stat($path);
                }

                return false;
            }
        }
    }

    if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
        include("phpvfscomposer://" . __DIR__ . '/..'.'/phpunit/phpunit/phpunit');
        exit(0);
    }
}

include __DIR__ . '/..'.'/phpunit/phpunit/phpunit';
 /var/www/spotweb/vendor/bin/phpunit: file name too long
hlugt commented 1 year ago

Hm, maybe the error sits in the spotweb repo? Noticed that the image from erikdevries/spotweb leads to the same errors on arm... Not sure how to interpret the issue I referred to, but maybe some commit in the spotweb repo causes this on linux (and thus mac as well) platforms?

jgeusebroek commented 1 year ago

I can't replicate this using ARM on my Mac. As you said, if it's also on another image this might be a local issue? What is the path you are mapping the data dir to? Can this be too long for the underlying file system?

hlugt commented 1 year ago

Hi, weird that on a mac it does not occur. As it seems it has to do with the symlink. Must be an arm vs x86 thingy then?

Anyway: I changed the git clone to the following in the dockerfile, and I have build a working image myself for now (and btw moved it to PHP8.1 while busy editing anyway).

Symlinks false can be done safely I think as the git repo is not used as a code repo anyway.... Have not checked for change of behaviour in a amd64 variant (or mac ofcourse).

Would be great if you could implement it if it does not break the amd64 images?

RUN git clone --no-checkout -b master --depth 1 --single-branch https://github.com/spotweb/spotweb.git /var/www/spotweb && \
    cd /var/www/spotweb && \
    git config core.symlinks false && \
    git checkout && \
    # rm -rf /var/www/spotweb/.git && \
    chmod -R 775 /var/www/spotweb && \
    chown -R www-data:www-data /var/www/spotweb

BTW, it goes wrong at pull time, so no path mapping in play yet... "standard" docker install on debian sbc's.

Oh, and I now see that you have an arm mac... Then I do not understand why it does occur at the arm sbc's I tried to pull it on... Tried all version's as said, so a type mismatch seems to be unlikely. Worst case I need to keep building them myself...

Another btw: I can see it on a local host (ie not in container) git clone easily as well. Normal clone: the vendor/bin/phpunit is unreadable. Following same procedure first no-checkout setting config and then checkout, file is readable. Maybe wait for source spotweb to get fixed if there is an confirmed issue...

jgeusebroek commented 1 year ago

Thanks for the patch, I applied your fix. Does it work for you? Also updated to PHP 8.1 ;)

hlugt commented 1 year ago

Great, it works for me!