JhumanJ / OpnForm

Beautiful Open-Source Form Builder
https://opnform.com
GNU Affero General Public License v3.0
2.22k stars 296 forks source link

Errors with laravel when using docker compose 'make up' #101

Closed mrysn closed 1 year ago

mrysn commented 1 year ago

Can anybody help or guide me getting past this error?

image

I am getting the same problem on an Intel iMac and Dell Intel server running CentOS 7.

Steps to recreate:

  1. clone the repo
  2. cd into the dir, run make up
JhumanJ commented 1 year ago

Can you try copying .env.docker to .env before running make?

mrysn commented 1 year ago

Thanks for your response, that certainly helped in getting further along. I now have the following problem:

image

 ⠿ Container opnform-database-1  Started                                                                                                                                                         5.7s

                                                                                      APPLICATION IN PRODUCTION.

  Do you really wish to run this command? (yes/no) [no]
❯ yes

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = postgres and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +39 vendor frames
  40  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
make: *** [.make.migrate] Error 1```
mrysn commented 1 year ago

Hi @JhumanJ any thoughts on how this could be resolved? Many thanks

JhumanJ commented 1 year ago

Not sure what happened, but it seems like the migration happens after the database was taken down.. Hence the connection refused error image

mrysn commented 1 year ago

When I attach to the database container there's the following error looping:

$ docker container attach opnform-database-1
2023-03-10 20:15:08.516 UTC [222] FATAL:  role "root" does not exist
2023-03-10 20:15:13.662 UTC [230] FATAL:  role "root" does not exist
2023-03-10 20:15:18.783 UTC [238] FATAL:  role "root" does not exist

When I CTRL-C I get some PG log output:

^C2023-03-10 20:16:47.278 UTC [1] LOG:  received fast shutdown request
2023-03-10 20:16:47.279 UTC [1] LOG:  aborting any active transactions
2023-03-10 20:16:47.284 UTC [1] LOG:  background worker "logical replication launcher" (PID 31) exited with exit code 1
2023-03-10 20:16:47.286 UTC [26] LOG:  shutting down
2023-03-10 20:16:47.289 UTC [26] LOG:  checkpoint starting: shutdown immediate
2023-03-10 20:16:47.310 UTC [26] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.004 s, sync=0.001 s, total=0.025 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2023-03-10 20:16:47.319 UTC [1] LOG:  database system is shut down

Any thoughts on what to try? I have a few ideas I'll try out

JhumanJ commented 1 year ago

This link maybe can help? https://stackoverflow.com/questions/60193781/postgres-with-docker-compose-gives-fatal-role-root-does-not-exist-error

mrysn commented 1 year ago

Still can't resolve this and I've tried the suggesstions from your link, thanks for that.

I've tried:

Still getting connection refused:

image

And this is the log for the database container:

image
mrysn commented 1 year ago

(Apologies accidentally closed the issue)

mrysn commented 1 year ago

I also tried to expose port 5432 on the database container, still getting connection refused. Is there a way to check how the connection attempt is being made?

Also is anybody seeing this problem completely from scratch? I have tried this on Intel and M2 Macs, Ubuntu and CentOS systems getting the same result every time.

mrysn commented 1 year ago

I've tried injecting a pg_hba.conf with the following line included host all all all trust and still getting connection refused. I think the issue may be happening where the db connection attempts are being made from migrate/artisan/laravel.

mrysn commented 1 year ago

Found the cause of the problem! The default MySQL port 3306 is being used when artisan migrate runs. I added this to .env and it seems to have sorted it: DB_PORT=5432

mrysn commented 1 year ago

@JhumanJ I also had to do another fix, in Makefile line 33 removed one hyphen before f docker compose run --rm php-cli artisan jwt:secret -f

JhumanJ commented 1 year ago

Thanks for reporting your findings. Here's the relevant commit: https://github.com/JhumanJ/OpnForm/commit/37965f33cd39542bdc13ca8ce1d4640d0df007bc I'm marking this as closed, please let us know if something else doesn't work!