make dev-setup fails to run properly
Closed this issue · 19 comments
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
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 dang. Can you share your .env
, .my.cnf
and .db.env
files? (A lot of secret files I know ðŸ˜)
@owerg did you copy the docker versions of the examples? The .env specifically has one I think.
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=
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
@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!
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.
@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).
Can you check existence and permissions for storage/logs/laravel.log
?
It is present and owned by root:root with 644 (RW/R/R) permissions.
I've never seen that one 😬 looks like a failure to write to the file? Maybe there are other files failing?
I haven't run into that either. You might double check that all of storage
and bootstrap/cache
are writable.
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.
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