Laravel-Pagebuilder icon indicating copy to clipboard operation
Laravel-Pagebuilder copied to clipboard

Problem with Docker

Open AnastasiaKremenetskaya opened this issue 4 years ago • 7 comments

When using docker router not working as it should work. And shows Asset not found to all assets in package.

Снимок экрана 2021-02-20 в 21 29 30

Above problems appear only when using PHPageBuilder with docker.

My .env

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=33060
DB_DATABASE=db
DB_USERNAME=root
DB_PASSWORD=secret

My config/pagebuilder

    'storage' => [
        'use_database' => true,
        'database' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST').':'.env('DB_PORT',3306),
            'database'  => env('DB_DATABASE'),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => 'pagebuilder__',
        ],
        'uploads_folder' => storage_path('app/pagebuilder/uploads')
    ],

AnastasiaKremenetskaya avatar Feb 20 '21 18:02 AnastasiaKremenetskaya

image

why do you have different ports in .env and config?

I think DB issue could not be the cause of "asset not found" error. What is the full path of app.css in browser?

dsultanr avatar Feb 21 '21 18:02 dsultanr

I don't have different ports. env('DB_PORT',3306), means that if DB_PORT in env is empty then use default 3306 port. Full path is http://localhost/assets/websitemanager/app.css

AnastasiaKremenetskaya avatar Feb 23 '21 10:02 AnastasiaKremenetskaya

but you have 33060 port in your .env

dsultanr avatar Feb 23 '21 14:02 dsultanr

Yes, that's why default 3306 port won't be used. 3306 is used only when DB_PORT in .env is empty, my DB_PORT is not empty.

AnastasiaKremenetskaya avatar Feb 23 '21 19:02 AnastasiaKremenetskaya

Hi @AnastasiaKremenetskaya , I have same issue did you find a solution for that?

ehsantalkhouncheh avatar Aug 23 '21 11:08 ehsantalkhouncheh

Hi @ehsantalkhouncheh No, forced to discard usage

AnastasiaKremenetskaya avatar Aug 23 '21 13:08 AnastasiaKremenetskaya

Not sure if this applies to everyone using Docker but it definitely applies when installing Laravel for dev using Laravel Sail.

In vendor/hansschouten/phpagebuilder/src/Core/helpers.php in the phpb_current_full_url() method the full URL is generated using SERVER['SERVER_NAME'] which in the case of these docker containers in windows and WSL2 (not sure about in mac OS) is generally 0.0.0.0.

Then in the phpb_current_relative_url() method the relative URL is generated using both the returned value from the above mentioned phpb_current_full_url() and the value in phpb_config('general.base_url'); which in most cases is probably http://localhost.

Changing the ENV or config value for base_url doesn't solve the issue as redirects are sent to 0.0.0.0 then which breaks in the WSL2/Docker environment.

bluekable avatar Dec 29 '22 10:12 bluekable