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

App doesnt connect to the database #51

Open
Sive0n opened this issue Jan 24, 2025 · 14 comments
Open

App doesnt connect to the database #51

Sive0n opened this issue Jan 24, 2025 · 14 comments
Assignees

Comments

@Sive0n
Copy link

Sive0n commented Jan 24, 2025

I've follow the instructions but it seems that while the data base is ready, the app can't reach it.

investbrain-app | SQLSTATE[HY000] [1045] Access denied for user 'investbrain'@'172.21.0.4' (using password: YES) (Connection: mysql, SQL: select exists (select 1 from information_schema.tables where table_schema = 'investbrain' and table_name = 'migrations' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as exists)
investbrain-app |
investbrain-app | at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
investbrain-app | 821▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
investbrain-app | 822▕ );
investbrain-app | 823▕ }
investbrain-app | 824▕
investbrain-app | ➜ 825▕ throw new QueryException(
investbrain-app | 826▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
investbrain-app | 827▕ );
investbrain-app | 828▕ }
investbrain-app | 829▕ }
investbrain-app |
investbrain-app | +39 vendor frames
investbrain-app |
investbrain-app | 40 artisan:13
investbrain-app | Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))
investbrain-app |
investbrain-app | > Waiting for database to be ready... retrying in 5 seconds.

@Sive0n Sive0n changed the title App doesnt connect to to database App doesnt connect to the database Jan 26, 2025
@hackeresq
Copy link
Collaborator

Interesting. Did you make any changes to the docker-compose.yml file?

I've just tagged a new release with updated install instructions. Want to give that a shot and see if it works better?

@Sive0n
Copy link
Author

Sive0n commented Jan 29, 2025

Had a look at your new instructions.
Nor needing nginx service, likely included in app now, is a good move.

I tried a fresh installation now and it seems to work, but the login page layout is not adapting well.
The images insanely huge. Could be because of the 4k screen?

Also I tried to register a new user and for this

The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append

@Sive0n
Copy link
Author

Sive0n commented Jan 29, 2025

Ok i fixed the error with the register, it was a permission problem.

The website however is unusable due to how big the images are showing for me (every image is scaling to "fullscreen").

@hackeresq
Copy link
Collaborator

Curious what the permissions problem was? Was it something unique to your set up? Or is it something that should be documented?

As far as the images looking "huge" - have you updated the APP_URL and ASSET_URL env variables? These are used by the front end to create absolute links to image, js, and css assets:

      APP_URL: "http://localhost:8000"
      ASSET_URL: "http://localhost:8000"

I suspect that's the issue.

@hackeresq hackeresq self-assigned this Jan 29, 2025
@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

The permission issue I'm trying to figure out, because it happen again after I did some changes and redeployed, which is strange.

Regarding the images, I'm not sure how would string affect the images, but I've tried it as you suggested both in the env and the compose file and nothing changed.

If it helps, when I zoom in/out within the browser the text and field do resize, but the images do not.
However, when I reduce the size of the browser window the images also resize, as if they are trying to fit the maximum size they can.

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

Ok this is strange, but I commented out the ASSET_URL line in the compose file and it looks nice now.
Could there be some sort of conflict when it exists in both the compose and the .env file?

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

So my .env file is a copy paste of yours, I just changed the port because that one was already in use for me.
So tried commenting all the "enviroment" section of the compose because all variable seem to exist in the .env, but I started to get the permission error.

I started to do some test uncommenting each line and narrowed it down to the SESSION_DRIVER and REDIS_HOST which can't be commented.

This compose works for me:

networks:
  investbrain-network:
    driver: bridge
services:
  app:
    image: investbrainapp/investbrain:latest
    container_name: investbrain-app
    restart: unless-stopped
    tty: true
    ports:
      - "${APP_PORT:-8000}:80"
    environment:
#      APP_KEY: "" # Generate a key using `openssl rand -base64 32`
#      APP_URL: "http://localhost:8100"
#      ASSET_URL: "http://localhost:8100"
#      DB_CONNECTION: mysql
#      DB_HOST: investbrain-mysql
#      DB_PORT: 3306
#      DB_DATABASE: ${DB_DATABASE:-investbrain}
#      DB_USERNAME: ${DB_USERNAME:-investbrain}
#      DB_PASSWORD: ${DB_PASSWORD:-investbrain}
      SESSION_DRIVER: redis
#      QUEUE_CONNECTION: redis
#      CACHE_STORE: redis
      REDIS_HOST: investbrain-redis
    volumes:
      - ./storage:/var/www/app/storage:delegated
    depends_on:
      - mysql
      - redis
    networks:
      - investbrain-network
  redis:
    image: redis:alpine
    container_name: investbrain-redis
    restart: unless-stopped
    tty: true
    networks:
      - investbrain-network
    volumes:
      - investbrain-redis:/data
  mysql:
    image: mysql:8.0
    container_name: investbrain-mysql
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-investbrain}
      MYSQL_USER: ${DB_USERNAME:-investbrain}
      MYSQL_PASSWORD: ${DB_PASSWORD:-investbrain}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-investbrain}
    command: 
      - --cte-max-recursion-depth=25000
    volumes:
      - investbrain-mysql:/var/lib/mysql
    networks:
      - investbrain-network
volumes:
  investbrain-redis:
  investbrain-mysql:

@hackeresq
Copy link
Collaborator

I don't think you can reliably have both a .env AND set environments in your compose file. Not even sure which environments Docker would prioritize. My recommendation is to choose one or the other.

To avoid this in future, I'll probably do something like this - so conflicts wont / cant occur:

  app:
    image: investbrainapp/investbrain:latest
    container_name: investbrain-app
    restart: unless-stopped
    tty: true
    ports:
      - "${APP_PORT:-8000}:80"
    environment:
      APP_KEY: ${APP_KEY:-""} # Generate a key using `openssl rand -base64 32`
      APP_URL: ${APP_URL:-http://localhost:8000}
      ASSET_URL: ${ASSET_URL:-http://localhost:8000}
      DB_CONNECTION: ${DB_CONNECTION:-mysql}
      DB_HOST: ${DB_HOST:-investbrain-mysql}
      DB_PORT: ${DB_PORT:-3306}
      DB_DATABASE: ${DB_DATABASE:-investbrain}
      DB_USERNAME: ${DB_USERNAME:-investbrain}
      DB_PASSWORD: ${DB_PASSWORD:-investbrain}
      SESSION_DRIVER: ${SESSION_DRIVER:-redis}
      QUEUE_CONNECTION: ${QUEUE_CONNECTION:-redis}
      CACHE_STORE: ${CACHE_STORE:-redis}
      REDIS_HOST: ${REDIS_HOST:-investbrain-redis}
    volumes:
      - ./storage:/var/www/app/storage:delegated
    depends_on:
      - mysql
      - redis
    networks:
      - investbrain-network

Would be curious if this works in your compose file?

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

Now I get this

The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/app/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: Unsupported cipher or incorrect key length. Supported ciphers are: aes-128-cbc, aes-256-cbc, aes-128-gcm, aes-256-gcm. Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}} Context: {"exception":{}}

@hackeresq
Copy link
Collaborator

Do you see a ./storage directory in the same directory as your docker-compose.yml file?

You're not the only one seeing the laravel.log permission error. I also saw them when I was re-working the container.

What user are you running docker with? Can you do a whoami ?

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

I usually use Komodo to manage my stacks.

But I tried just not directly via SSH with root user and am getting the same error.

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

Oh and yes there is a "storage" folder in the same place as the yml.
Edit:
It has 2 folders "framework" owned user 33 and a "logs" owned by root

@Sive0n
Copy link
Author

Sive0n commented Jan 30, 2025

I tried starting from scratch with docker compose down, and also deleted storage folder.
then did a docker compose -p investbrain -f compose.yaml --env-file .env up -d.

Now I get a symphony error:

InvalidArgumentException:
Please provide a valid cache path.

  at /var/www/app/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php:67
  at Illuminate\View\Compilers\Compiler->__construct(object(Filesystem), false, '', true, 'php')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/View/ViewServiceProvider.php:97)
  at Illuminate\View\ViewServiceProvider->Illuminate\View\{closure}(object(Application), array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:937)
  at Illuminate\Container\Container->build(object(Closure))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:819)
  at Illuminate\Container\Container->resolve('blade.compiler', array(), true)
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1051)
  at Illuminate\Foundation\Application->resolve('blade.compiler', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:755)
  at Illuminate\Container\Container->make('blade.compiler', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1033)
  at Illuminate\Foundation\Application->make('blade.compiler')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:1565)
  at Illuminate\Container\Container->offsetGet('blade.compiler')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:239)
  at Illuminate\Support\Facades\Facade::resolveFacadeInstance('blade.compiler')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:210)
  at Illuminate\Support\Facades\Facade::getFacadeRoot()
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:355)
  at Illuminate\Support\Facades\Facade::__callStatic('component', array('BladeUI\\Icons\\Components\\Svg', 'c-academic-cap', 'heroicon'))
     (/var/www/app/vendor/blade-ui-kit/blade-icons/src/Factory.php:108)
  at BladeUI\Icons\Factory->registerComponents()
     (/var/www/app/vendor/blade-ui-kit/blade-icons/src/BladeIconsServiceProvider.php:66)
  at BladeUI\Icons\BladeIconsServiceProvider->BladeUI\Icons\{closure}(object(Factory), object(Application))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:1417)
  at Illuminate\Container\Container->fireCallbackArray(object(Factory), array(object(Closure), object(Closure), object(Closure), object(Closure), object(Closure)))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:1353)
  at Illuminate\Container\Container->fireAfterResolvingCallbacks('view', object(Factory))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:1339)
  at Illuminate\Container\Container->fireResolvingCallbacks('view', object(Factory))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:837)
  at Illuminate\Container\Container->resolve('view', array(), true)
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1051)
  at Illuminate\Foundation\Application->resolve('view', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:755)
  at Illuminate\Container\Container->make('view', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1033)
  at Illuminate\Foundation\Application->make('view')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php:268)
  at Illuminate\Foundation\Providers\FoundationServiceProvider->Illuminate\Foundation\Providers\{closure}(object(Application), array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:937)
  at Illuminate\Container\Container->build(object(Closure))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:819)
  at Illuminate\Container\Container->resolve('Illuminate\\Foundation\\Exceptions\\Renderer\\Renderer', array(), true)
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1051)
  at Illuminate\Foundation\Application->resolve('Illuminate\\Foundation\\Exceptions\\Renderer\\Renderer', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:755)
  at Illuminate\Container\Container->make('Illuminate\\Foundation\\Exceptions\\Renderer\\Renderer', array())
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1033)
  at Illuminate\Foundation\Application->make('Illuminate\\Foundation\\Exceptions\\Renderer\\Renderer')
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:847)
  at Illuminate\Foundation\Exceptions\Handler->renderExceptionContent(object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:828)
  at Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:807)
  at Illuminate\Foundation\Exceptions\Handler->prepareResponse(object(Request), object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:706)
  at Illuminate\Foundation\Exceptions\Handler->renderExceptionResponse(object(Request), object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:594)
  at Illuminate\Foundation\Exceptions\Handler->render(object(Request), object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:225)
  at Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:202)
  at Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(object(UnexpectedValueException))
     (/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:290)
  at Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(object(UnexpectedValueException))      

@hackeresq
Copy link
Collaborator

Appreciate your patience in troubleshooting this with me.

All of these error messages are pointing to permission issues. I just tagged a new release that should address these issues.

It's still building, but should be on ghcr and dockerhub shortly!

Pretty confident that should solve all these issues once and for all! 👍

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

2 participants