Closed martinjaeger closed 1 year ago
Hi Martin,
Docker uses the same user to interact with the system that you fired it up with. In other words, all new directories and co. are created by that user. As far as I know, you need to
As far as I know, there are two possible solutions for it;
1 add your current user to www-data
user group
chown
to a user that is in the www-data
groupWhat you're looking for point 2, its actually in the readme see: Migrate the Database. You need to run php artisan migrate --seed
inside the Laravel container that will create all database tables including an admin user with admin@admin.com and basic-password.
Thanks for the quick response.
Docker uses the same user to interact with the system that you fired it up with. In other words, all new directories and co. are created by that user.
For some reason, the newly created files were owned by root
even though I ran docker-compose
as a normal user. Will try to look into that again.
What you're looking for point 2, its actually in the readme see: Migrate the Database. You need to run
php artisan migrate --seed
inside the Laravel container that will create all database tables including an admin user with admin@admin.com and basic-password.
Ok, seems like I was a bit confused by the word migrate as I thought that this would only be required if you have a previous installation with different database.
I've done that and still can't login. With above user/password combination I don't get any error message, but I don't get forwarded to the actual website. Wrong passwords result in an error message as this one:
Here is the log of the failed attempt with correct password:
laravel | 172.18.0.4 - - [11/May/2021:18:24:05 +0000] "POST /api/auth/login HTTP/1.1" 200 714 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
nginx-proxy | nginx.1 | mpmanager.local 172.18.0.1 - - [11/May/2021:18:24:05 +0000] "POST /api/auth/login HTTP/1.1" 200 473 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
laravel | 172.18.0.4 - - [11/May/2021:18:24:05 +0000] "GET /api/settings/main HTTP/1.1" 200 533 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
nginx-proxy | nginx.1 | mpmanager.local 172.18.0.1 - - [11/May/2021:18:24:05 +0000] "GET /api/settings/main HTTP/1.1" 200 292 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
laravel | 172.18.0.4 - - [11/May/2021:18:24:05 +0000] "GET /api/map-settings HTTP/1.1" 200 396 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
nginx-proxy | nginx.1 | mpmanager.local 172.18.0.1 - - [11/May/2021:18:24:05 +0000] "GET /api/map-settings HTTP/1.1" 200 155 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
laravel | 172.18.0.4 - - [11/May/2021:18:24:05 +0000] "GET /api/ticket-settings HTTP/1.1" 200 438 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
nginx-proxy | nginx.1 | mpmanager.local 172.18.0.1 - - [11/May/2021:18:24:05 +0000] "GET /api/ticket-settings HTTP/1.1" 200 197 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
laravel | 172.18.0.4 - - [11/May/2021:18:24:05 +0000] "POST /api/auth/refresh HTTP/1.1" 400 470 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
nginx-proxy | nginx.1 | mpmanager.local 172.18.0.1 - - [11/May/2021:18:24:05 +0000] "POST /api/auth/refresh HTTP/1.1" 400 220 "http://mpmanager.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
Any ideas?
To be honest, that's the first time we're facing an issue like that.
According to the logs, the login was accepted by the back-end also Vue understood it and started to pull the base settings from the server. However, the part which refreshes/extends the JWT token on each page-load failed to re-create a new one.
Could you kindly paste both your storage/logs/laravel.log
file and the response of that request refresh
(in your network tab in the console) here too?
Unfortunately I was not able to reproduce that error. I installed a fresh copy(even deleted elder docker images) on Centos7 , Ubuntu20.04 and a Mac-BigSur.
I use Docker in version 20.10.02 and docker-compose in version 1.24.1.
Ok, seems to be another file access rights problem. Here is the output from storage/logs/laravel.log
:
[2021-05-12 04:51:09] development.ERROR: file_put_contents(/var/www/html/mpmanager/storage/framework/cache/data/a5/6f/a56f67bff77a51d486911549092b9a4f310e1df3): failed to open stream: No such file or directory {"userId":1,"exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/html/mpmanager/storage/framework/cache/data/a5/6f/a56f67bff77a51d486911549092b9a4f310e1df3): failed to open stream: No such file or directory at /var/www/html/mpmanager/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:135)
[stacktrace]
Allowing write access to the cache folder did the trick. Now I can log in.
As far as I understand, docker does not necessarily use the same uids/gids as the host, so changing the group of the folders to www-data
will only work if the host system is the same as the system used by the docker container (or if the gid is the same by coincidence). I'm running Manjaro, where http
has gid 33. Apparently it's the same as ẁww-data
in the laravel
container, so we are lucky. But it would be good to make this more portable by using docker volumes instead of the local file system for any folders that need write access.
I'll probably create a PR with a suggestion later today.
Thanks a lot for open-sourcing the MPManager!
I'm trying it out with the instructions in the Readme.md, but I faced a few small challenges.
A
chmod a+w
solved the issue, but this doesn't look like a very clean solution. Did I do something wrong?.env
file or anything similar to set it via Docker, as far as I can see.