devict / votelocal

A web app for receiving local voting information via SMS
15 stars 16 forks source link

make dev-setup fails to run properly #116

Closed owerg closed 4 years ago

owerg commented 4 years ago

I am trying to set up the dev environment for the first time. I am sure I just have something set up incorrectly, but the instructions don't give me any clues what I've done wrong. Here is what I'm seeing for the output:

docker-compose run --rm php php artisan migrate

   Illuminate\Database\QueryException 

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

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

      +36 vendor frames 
  37  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
make: *** [Makefile:39: db-migrate] Error 1
sethetter commented 4 years ago

I think you need to run make dev running for that to work so the database is up and ready to receive migrations. Give that a shot and let me know!

owerg commented 4 years ago

No luck. I may have to wipe it all out and try again from scratch tomorrow.

On Thu, Oct 1, 2020, 4:05 PM Seth Etter notifications@github.com wrote:

I think you need to run make dev running for that to work so the database is up and ready to receive migrations. Give that a shot and let me know!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/devict/votelocal/issues/116#issuecomment-702397292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQKKKXVVVZVORBDSFI42ODSITVJ3ANCNFSM4SA3R4DA .

sethetter commented 4 years ago

@owerg dang. Can you share your .env, .my.cnf and .db.env files? (A lot of secret files I know 😭)

owerg commented 4 years ago

Well that's maybe where I messed up. I just did a cp of the 3 example files from the initial git clone. So those 3 files are identical to mine.

On Thu, Oct 1, 2020, 5:26 PM Seth Etter notifications@github.com wrote:

@owerg https://github.com/owerg dang. Can you share your .env, .my.cnf and .db.env files? (A lot of secret files I know 😭)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/devict/votelocal/issues/116#issuecomment-702429521, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQKKKWDKUW7QOE64KWLCWLSIT6YNANCNFSM4SA3R4DA .

sethetter commented 4 years ago

@owerg did you copy the docker versions of the examples? The .env specifically has one I think.

owerg commented 4 years ago

It looks like I did grab the docker versions:

cp .env.docker.example .env
cp .db.env.docker.example .db.env
cp .my.cnf.example .my.cnf

The .db.env and .my.cnf files still match the example versions. .env somehow has an updated APP_KEY:

< APP_KEY=
---
> APP_KEY=base64:2S2xbr7xRTY9LAUc4UDPnzJZLYFEENzU9Ti2rcq9Rv8=
owerg commented 4 years ago

I cleaned things up and started fresh via:

docker rm -f $(docker ps -a -q)
docker volume rm $(docker volume ls -q)
sudo rm -rf votelocal
git clone git@github.com:devict/votelocal.git
cd votelocal
cp .env.docker.example .env
cp .db.env.docker.example .db.env
cp .my.cnf.example .my.cnf

From here, I tried doing a couple things in parallel: Window 1: make dev Window 1: Wait until webpack.Progress reached 100% (See attached 1_make_dev.txt -- this is everything prior to the Ctrl+C near the end) Window 2: make dev-setup (See attached 2_make_dev_setup.txt -- you can see it fail with SQLSTATE[HY000] [2002] Connection timed out) Window 1: Ctrl+C to stop the dev machines Window 1: make dev Window 1: Wait until webpack.Progress reached 100% (See attached 3_make_dev_2nd_attempt.txt) Window 2: make dev-setup (See attached 4_make_dev_setup_2nd_attempt.txt -- this time it fails with SQLSTATE[HY000] [1130] Host '172.18.0.7' is not allowed to connect to this MySQL server)

I did notice that the db container exited early in the first make dev attempt and it stayed up in the 2nd attempt. This probably explains the differences between the failures in make dev-setup. I'm still not sure what I'm missing to get things to move along, though.

If this is taking too much of your time & effort and you get sick of helping, just let me know. I can close this and poke at some other project. But I'm more than happy to keep sending whatever debug info you need as well.

1_make_dev.txt 2_make_dev_setup.txt 3_make_dev_2nd_attempt.txt 4_make_dev_setup_2nd_attempt.txt

sethetter commented 4 years ago

@owerg I'm curious where the issue is so I can get it added to the README and hopefully help others who may be running into this issue. I'm going to try and recreate locally now, and we'll go from there. I'll keep you posted!

sethetter commented 4 years ago

@owerg what OS are you operating on?

sethetter commented 4 years ago

Good news! I'm standing things up from scratch and seeing the same issue. Once I get it worked out I'll update the README and report back.

sethetter commented 4 years ago

@owerg I think I have the issue fixed! Pull down the latest master.

The issue was that the .my.cnf file wasn't allowing mysql client connections. It was left over from some fiddling I was doing awhile back and turns out to not be necessary anymore.

Let me know if that solves the problem!

$ git pull
$ docker-compose down -v # Deletes containers and volumes for the project
$ make dev

Then make db-migrate && make db-seed in another terminal. The other dev-setup tasks should already be covered (app key, mainly).

owerg commented 4 years ago

Much better this time! Everything appears to have worked and come up. I'm seeing the attached error when I open localhost:8002 in a browser, though. error

sethetter commented 4 years ago

Can you check existence and permissions for storage/logs/laravel.log?

owerg commented 4 years ago

It is present and owned by root:root with 644 (RW/R/R) permissions.

owerg commented 4 years ago

If I chmod it to 666, it gets farther, but I run into other issues. Probably permission related as well?

error2

EDIT: The command I used was: sudo chmod 666 storage/logs/laravel.log

sethetter commented 4 years ago

I've never seen that one 😬 looks like a failure to write to the file? Maybe there are other files failing?

imacrayon commented 4 years ago

I haven't run into that either. You might double check that all of storage and bootstrap/cache are writable.

owerg commented 4 years ago

I think that was the issue. I'm running docker as a regular user that belongs to the docker group. It looks like storage and bootstrap belong to the user with 755 permissions and then some root:root files are peppered in underneath there.

As the regular user I went ahead and did:

chmod -R a+w,g+w storage/
chmod -R a+w,g+w bootstrap/

It looks like things are up and running now. There are some new files that belong to www-data:www-data in storaga/framework/views/ which seems to confirm that www-data couldn't create the necessary files before.

EDIT: Thank you both for all your help here.

owerg commented 4 years ago

I updated the DOCKER.md file with a couple more details based on what I found from here: https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel