Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.04k stars 885 forks source link

[Bug] Basset check error on backpack:install - docker composer #5444

Closed rdesorme closed 6 months ago

rdesorme commented 6 months ago

Bug report

What I did

I create a new project and run php artisan backpack:install --no-interaction

What I expected to happen

No error (the project is correctly installed).

What happened

I get an error from the basset:check command called at the end of backpack:install - Here

cURL error 7: Failed to connect to myproject.localhost port 443: Connection refused

What I've already tried to fix it

Search for command option or .env variables to skip basset:check when BASSET_DEV_MODE=true

Is it a bug in the latest version of Backpack?

Yes

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.2.15 (cli) (built: Jan 20 2024 14:16:39) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.15, Copyright (c) Zend Technologies with Zend OPcache v8.2.15, Copyright (c), by Zend Technologies

LARAVEL VERSION:

10.43.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2 backpack/crud: 6.6.2 backpack/generators: v4.0.3 backpack/pro: 2.1.2 backpack/theme-tabler: 1.2.0

karandatwani92 commented 6 months ago

Hey @rdesorme

Can you check the APP_URL in your .env file;

rdesorme commented 6 months ago

Hey,

The APP_URL is correct and I can access to https://myproject.localhost in my browser

I'm running the project with docker and I found that I need to set APP_URL=http://php-apache to work with php artisan commands, but switching the variable every time will be a pain

Is it possible to skip basset check on local? Or at least with an explicit option like --no-check?

pxpm commented 6 months ago

@rdesorme it seems to me that you need to set APP_URL=http://php-apache because that's the host your docker maps to ? Having 2 different APP_URL to me means 2 different environments, is like having APP_URL=http://something both for development and for production. It's an .env file so it "represents" one environment.

What you said by other words is: when I a run "php artisan some:command", "app()->url()" will return "http://php-apache", in the same application, if I am accessing via browser, "app()->url()" returns "https://myproject.localhost/"

I don't think that is correct in anyway, as the app url should return the same value, because the application is the same.

I would check your setup again, because I don't think there is a need for a --no-check command.

I may be wrong, I don't use docker as my main development tool, so bare with me if I said something stupid and let me know some more details so that I can understand the problem.

Cheers

rdesorme commented 6 months ago

Hey @pxpm

Yes it should be done in docker's config, I was taking the problem in the wrong way.

So problem solved, thanks !


If anyone have this kind of problem, here the solution :

Edit your docker-composer.yml file like this:

 version: "3.8"

 services:
   # ... Some services
   ####################
   # PHP and Apache Container to access website from browser
   ####################
   php-apache:
     # ... Some config
     networks:
-      - webgateway
-      - internal
+      webgateway:
+      internal:
+        aliases:
+          - myproject.localhost
   ####################
   # Workspace Container to run composer and artisan commands
   ####################
   workspace:
     # ... Some config
     networks:
       - internal

 networks:
   webgateway:
     external: true
   internal:
     driver: bridge
pxpm commented 6 months ago

thanks for posting the solution @rdesorme . very much appreciated, truly 🙏

Happy it's working fine for you now. Let us know if you experience other issues.