Kovah / LinkAce

LinkAce is a self-hosted archive to collect links of your favorite websites.
https://www.linkace.org
GNU General Public License v3.0
2.64k stars 164 forks source link

Filesystem permission issues while trying to import #169

Closed dokbua closed 3 years ago

dokbua commented 4 years ago

I was struggling with the setup instructions for some time:

4. Run the Setup
After you started the Docker containers, you are almost ready to run the setup. Before the setup, we have to generate a secret key. Please note that linkace_php_1 is the name of your PHP container here. It may differ from your name. You will find the name of your container in the output of the previous command, but will most likely end with _php_1.

docker-compose run php php artisan key:generate

Eventually I found that the working command should be

docker exec -it linkace_app_1 php artisan key:generate

Providing this to help others in the same situation, but it would probably be an idea to fix the instructions - both here an on the website.

dokbua commented 4 years ago

Next problem: For a test I exported my chrome bookmarks, and tried to import them, but immediately got the error

Something went wrong while trying to import the bookmarks. Please consult the application logs.

I'm not sure exactly what application logs I'm supposed to consult. Nothing under the logs directory, and docker logs from all containers also don't provide any details for this.

PS. I'm able to add individual links. It's just the import that fails.

Kovah commented 4 years ago

Hi! Thanks for trying LinkAce.

You are right, the command is wrong because there were some changes in the last weeks. It should be docker-compose run app php artisan key:generate.

About the bookmark import: please have a look at the storage/logs directory in the Docker container, or in the /logs directory if you have - ./logs:/app/storage/logs in your docker-compose file. If there is no log file, please make sure that the directory is writable. If there is a log file, please post the error.

dokbua commented 4 years ago

Actually docker creates the required directories with the PUID/PGID set in the app. Normally this can be set as an ENV but it has no effect here.

I had to do a lot of changes to the docker-compose.yml to get it to run at all, but I now started over again. First obstacle is that linkace_nginx_1 keeps restarting. A docker logs linkace_nginx_1 reveals:

nginx: [emerg] host not found in upstream "php" in /opt/bitnami/nginx/conf/server_blocks/linkace.conf:50

Kovah commented 4 years ago

Please have a look at https://github.com/Kovah/LinkAce/issues/164#issuecomment-710103482

dokbua commented 4 years ago

This is really weird - I thought I updated this yesterday but I don't see my post today. Probably I was dreaming. Here we go again.

After making the change in #164 it now starts, but still, trying to import links from chrom still fails. Now I see the following in the log:

[2020-10-27 19:21:01] production.ERROR: mkdir(): Permission denied {"userId":1,"exception":"[object] (ErrorException(code: 0): mkdir(): Permission denied at /app/vendor/katzgrau/klogger/src/Logger.php:119)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /app/vendor/katzgrau/klogger/src/Logger.php(119): mkdir()
#2 /app/vendor/shaarli/netscape-bookmark-parser/NetscapeBookmarkParser.php(66): Katzgrau\\KLogger\\Logger->__construct()
#3 /app/app/Http/Controllers/App/ImportController.php(44): Shaarli\\NetscapeBookmarkParser\\NetscapeBookmarkParser->__construct()
#4 [internal function]: App\\Http\\Controllers\\App\\ImportController->doImport()
#5 /app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array()
#6 /app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#7 /app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#8 /app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(196): Illuminate\\Routing\\Route->runController()
#9 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\\Routing\\Route->run()
#10 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#11 /app/app/Http/Middleware/SettingsMiddleware.php(32): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#12 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\SettingsMiddleware->handle()
#13 /app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#14 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#15 /app/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#16 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle()
#17 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(77): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#18 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#19 /app/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#20 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#21 /app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#22 /app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#23 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()
#24 /app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#26 /app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#28 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then()
#30 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack()
#31 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute()
#32 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute()
#33 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch()
#34 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#35 /app/app/Http/Middleware/SetupCheckMiddleware.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\SetupCheckMiddleware->handle()
#37 /app/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()
#39 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#41 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#43 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#45 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle()
#47 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then()
#49 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#50 /app/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
#51 {main}
"}

It seems it gets a write error inside the container, not sure what to do about that.

Also, I noticed that it runs with UID 1 - daemon. Normally it should be possible to set the effective UID/PID in the docker start script, but I don't see this option here. Is that perhaps something you could add at some point?

Kovah commented 4 years ago

Have to take a look into this. Please be patient.

napo789 commented 4 years ago

Hello,

I have the exact same writing problem when I try to import.

Kovah commented 4 years ago

Please test this with the new release.

napo789 commented 4 years ago

it works for me. I launched a simple update-docker.sh

Thanks for your time !

dokbua commented 4 years ago

Sorry, it still doesn't work here. I shut down the stack, deleted everything, downloaded from the github page, modified as required, did the up, the page came up, I go to import, pick a html file from a chrome export, and after having run for a while it dies with the error message "Something went wrong while trying to import the bookmarks. Please consult the application logs."

I don't see anything obvious in the logs though.

Also, would it be possible to add support for PUID/PGID environment variables so it doesn't run with root permissions, that would be nice!

root@docker:/data/linkace# docker-compose logs
Attaching to linkace_nginx_1, linkace_app_1, linkace_db_1, linkace_redis_1
db_1     | mariadb 01:18:16.84
db_1     | mariadb 01:18:16.84 Welcome to the Bitnami mariadb container
db_1     | mariadb 01:18:16.84 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-mariadb
db_1     | mariadb 01:18:16.85 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-mariadb/issues
db_1     | mariadb 01:18:16.85
db_1     | mariadb 01:18:16.85 INFO  ==> ** Starting MariaDB setup **
db_1     | mariadb 01:18:16.88 INFO  ==> Validating settings in MYSQL_*/MARIADB_* env vars
db_1     | mariadb 01:18:16.89 INFO  ==> Initializing mariadb database
db_1     | mariadb 01:18:16.91 INFO  ==> Updating 'my.cnf' with custom configuration
db_1     | mariadb 01:18:16.92 INFO  ==> Setting user option
db_1     | mariadb 01:18:16.98 INFO  ==> Using persisted data
db_1     | mariadb 01:18:17.03 INFO  ==> Running mysql_upgrade
db_1     | mariadb 01:18:17.04 INFO  ==> Starting mariadb in background
db_1     | mariadb 01:18:42.47 INFO  ==> Stopping mariadb
db_1     | mariadb 01:18:44.48 INFO  ==> ** MariaDB setup finished! **
db_1     |
db_1     | mariadb 01:18:44.53 INFO  ==> ** Starting MariaDB **
db_1     | 2020-11-11  1:18:44 0 [Note] /opt/bitnami/mariadb/sbin/mysqld (mysqld 10.5.6-MariaDB) starting as process 1 ...
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Using Linux native AIO
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Uses event mutexes
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Number of pools: 1
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Using generic crc32 instructions
db_1     | 2020-11-11  1:18:44 0 [Note] mysqld: O_TMPFILE is not supported on /opt/bitnami/mariadb/tmp (disabling future attempts)
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Completed initialization of buffer pool
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: 128 rollback segments are active.
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: 10.5.6 started; log sequence number 45397; transaction id 21
db_1     | 2020-11-11  1:18:44 0 [Note] Plugin 'FEEDBACK' is disabled.
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Loading buffer pool(s) from /bitnami/mariadb/data/ib_buffer_pool
db_1     | 2020-11-11  1:18:44 0 [Note] InnoDB: Buffer pool(s) load completed at 201111  1:18:44
db_1     | 2020-11-11  1:18:44 0 [Note] Server socket created on IP: '0.0.0.0'.
db_1     | 2020-11-11  1:18:44 0 [Warning] 'proxies_priv' entry '@% root@68c2da6f69c1' ignored in --skip-name-resolve mode.
db_1     | 2020-11-11  1:18:44 0 [Note] Reading of all Master_info entries succeeded
db_1     | 2020-11-11  1:18:44 0 [Note] Added new Master_info '' to hash table
db_1     | 2020-11-11  1:18:44 0 [Note] /opt/bitnami/mariadb/sbin/mysqld: ready for connections.
db_1     | Version: '10.5.6-MariaDB'  socket: '/opt/bitnami/mariadb/tmp/mysql.sock'  port: 3306  Source distribution
redis_1  | redis 01:18:16.67
redis_1  | redis 01:18:16.67 Welcome to the Bitnami redis container
redis_1  | redis 01:18:16.68 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-redis
redis_1  | redis 01:18:16.68 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-redis/issues
redis_1  | redis 01:18:16.68
redis_1  | redis 01:18:16.68 INFO  ==> ** Starting Redis setup **
redis_1  | redis 01:18:16.71 INFO  ==> Initializing Redis
redis_1  | redis 01:18:16.73 INFO  ==> Setting Redis config file
redis_1  | redis 01:18:16.77 INFO  ==> ** Redis setup finished! **
redis_1  |
redis_1  | redis 01:18:16.79 INFO  ==> ** Starting Redis **
redis_1  | 1:C 11 Nov 2020 01:18:16.809 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 11 Nov 2020 01:18:16.809 # Redis version=6.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 11 Nov 2020 01:18:16.809 # Configuration loaded
redis_1  |                 _._
redis_1  |            _.-``__ ''-._
redis_1  |       _.-``    `.  `_.  ''-._           Redis 6.0.8 (00000000/0) 64 bit
redis_1  |   .-`` .-```.  ```\/    _.,_ ''-._
redis_1  |  (    '      ,       .-`  | `,    )     Running in standalone mode
redis_1  |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
redis_1  |  |    `-._   `._    /     _.-'    |     PID: 1
redis_1  |   `-._    `-._  `-./  _.-'    _.-'
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|
redis_1  |  |    `-._`-._        _.-'_.-'    |           http://redis.io
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'
redis_1  |  |`-._`-._    `-.__.-'    _.-'_.-'|
redis_1  |  |    `-._`-._        _.-'_.-'    |
redis_1  |   `-._    `-._`-.__.-'_.-'    _.-'
redis_1  |       `-._    `-.__.-'    _.-'
redis_1  |           `-._        _.-'
redis_1  |               `-.__.-'
redis_1  |
redis_1  | 1:M 11 Nov 2020 01:18:16.811 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 11 Nov 2020 01:18:16.811 # Server initialized
redis_1  | 1:M 11 Nov 2020 01:18:16.811 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 11 Nov 2020 01:18:16.811 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled (set to 'madvise' or 'never').
redis_1  | 1:M 11 Nov 2020 01:18:16.812 * Ready to accept connections
nginx_1  | nginx 01:18:21.59
nginx_1  | nginx 01:18:21.59 Welcome to the Bitnami nginx container
nginx_1  | nginx 01:18:21.59 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-nginx
nginx_1  | nginx 01:18:21.59 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-nginx/issues
nginx_1  | nginx 01:18:21.59
nginx_1  | nginx 01:18:21.60 INFO  ==> ** Starting NGINX setup **
nginx_1  | nginx 01:18:21.62 INFO  ==> Validating settings in NGINX_* env vars
nginx_1  | nginx 01:18:21.63 INFO  ==> Initializing NGINX
nginx_1  |
nginx_1  | nginx 01:18:21.65 INFO  ==> ** NGINX setup finished! **
nginx_1  | nginx 01:18:21.66 INFO  ==> ** Starting NGINX **
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:02 +0000] "GET / HTTP/1.1" 302 398 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:03 +0000] "GET /setup/start HTTP/1.1" 200 990 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:03 +0000] "GET /setup/favicon.svg HTTP/1.1" 404 178 "http://docker.home:8170/setup/start" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:03 +0000] "GET /setup/favicon-32x32.png HTTP/1.1" 404 178 "http://docker.home:8170/setup/start" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:03 +0000] "GET /setup/favicon-16x16.png HTTP/1.1" 404 178 "http://docker.home:8170/setup/start" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:07 +0000] "GET /setup/requirements HTTP/1.1" 200 1043 "http://docker.home:8170/setup/start" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:09 +0000] "GET /setup/database HTTP/1.1" 200 1342 "http://docker.home:8170/setup/requirements" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:24 +0000] "POST /setup/database HTTP/1.1" 302 406 "http://docker.home:8170/setup/database" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:19:24 +0000] "GET /setup/account HTTP/1.1" 200 1258 "http://docker.home:8170/setup/database" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:02 +0000] "POST /setup/account HTTP/1.1" 302 410 "http://docker.home:8170/setup/account" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:02 +0000] "GET /setup/complete HTTP/1.1" 200 912 "http://docker.home:8170/setup/account" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:06 +0000] "GET /dashboard HTTP/1.1" 200 3733 "http://docker.home:8170/setup/complete" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:18 +0000] "GET /links/create HTTP/1.1" 200 4023 "http://docker.home:8170/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:19 +0000] "GET /links/favicon.svg HTTP/1.1" 404 178 "http://docker.home:8170/links/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:19 +0000] "GET /links/favicon-32x32.png HTTP/1.1" 404 178 "http://docker.home:8170/links/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:19 +0000] "GET /links/favicon-16x16.png HTTP/1.1" 404 178 "http://docker.home:8170/links/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:23 +0000] "GET /dashboard HTTP/1.1" 200 3733 "http://docker.home:8170/links/create" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:27 +0000] "GET /import HTTP/1.1" 200 3750 "http://docker.home:8170/dashboard" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
nginx_1  | 192.168.1.51 - - [11/Nov/2020:01:20:44 +0000] "POST /import HTTP/1.1" 500 2943 "http://docker.home:8170/import" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
root@docker:/data/linkace#
Kovah commented 4 years ago

What about the application logs in the storage/logs directory? PHP issues should be logged there. The log path of the import library changed in this release should not log anything to the storage/logs directory.

Setting a different user id is not supported via environment variables yet, but may be done by editing configuration files. Advanced image: https://github.com/bitnami/bitnami-docker-php-fpm#configuration Simple image: https://dockerfile.readthedocs.io/en/latest/content/DockerImages/dockerfiles/php.html

dokbua commented 4 years ago

The error appears to still be the same: [2020-11-11 09:44:37] local.ERROR: mkdir(): Permission denied {"userId":1,"exception":"[object] (ErrorException(code: 0): mkdir(): Permission denied at /app/vendor/katzgrau/klogger/src/Logger.php:119)

I noticed that folders are variously created with UID 1 (daemon) and UID 0 (root). For example the logs folder are created as root, but nothing can be written to it until it has been chown to daemon.

Sorry I am not a programmer and don't have much experience modifying the Dockerfile. All docker containers I've seen so far provide the PUID/PGID setting as part of the environment settings.

Kovah commented 4 years ago

If you can't solve the permission issues you should remove the mounting of any logs for now. Remove - ./logs:/app/storage/logs from the docker-compose file. This should prvent permission issues based on your host file system.

Nothing must be done in the Dockerfiles. The user running PHP can be set in configuration files. Please see the above links I shared.

dokbua commented 4 years ago

I have already read through all the links you provided. The only reference to UID I see is

This image is using supervisor and runs the daemon under user application (UID 1000; GID 1000) as default. If the container is started under a different user the daemon will be run under the specified uid.

I don't see how that is supposed to be of any help. Anyway, I commented out the logs line, and ran it, but it still comes up with the same error as before

Something went wrong while trying to import the bookmarks. Please consult the application logs.

I then cleaned up the whole thing and started over. Not easy as you have different instructions on different pages, but eventually I have it boiled down to this:

# docker-compose down
Stopping linkace_nginx_1 ... done
Stopping linkace_app_1   ... done
Stopping linkace_redis_1 ... done
Stopping linkace_db_1    ... done
Removing linkace_app_run_4e0db3c8e7f4 ... done
Removing linkace_nginx_1              ... done
Removing linkace_app_1                ... done
Removing linkace_redis_1              ... done
Removing linkace_db_1                 ... done
Removing network linkace_default
# docker system prune -a
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all images without at least one container associated to them
        - all build cache
Are you sure you want to continue? [y/N] y
Deleted Images:
...
(remove any unused db volumes, remove .env, replace with a fresh and with modified passwords etc of course)
# docker-compose up -d
Creating network "linkace_default" with the default driver
Creating volume "linkace_linkace_app" with default driver
Creating volume "linkace_db" with local driver
Pulling db (bitnami/mariadb:10.5)...
...
Status: Downloaded newer image for bitnami/mariadb:10.5
Pulling app (linkace/linkace:latest)...
...
Status: Downloaded newer image for linkace/linkace:latest
Pulling nginx (bitnami/nginx:1.19)...
...
Status: Downloaded newer image for bitnami/nginx:1.19
Pulling redis (bitnami/redis:6.0)...
...
Status: Downloaded newer image for bitnami/redis:6.0
Creating linkace_db_1    ... done
Creating linkace_redis_1 ... done
Creating linkace_app_1   ... done
Creating linkace_nginx_1 ... done
# docker-compose ps
     Name                    Command               State                Ports
-------------------------------------------------------------------------------------------
linkace_app_1     php-fpm -F --pid /opt/bitn ...   Up      9000/tcp
linkace_db_1      /opt/bitnami/scripts/maria ...   Up      3306/tcp
linkace_nginx_1   /opt/bitnami/scripts/nginx ...   Up      0.0.0.0:8170->8080/tcp, 8443/tcp
linkace_redis_1   /opt/bitnami/scripts/redis ...   Up      6379/tcp
# docker exec -it linkace_app_1 php artisan key:generate
Application key set successfully.
# docker exec -it linkace_app_1 bash -c "php artisan registeruser rcd my@user.com"

In Connection.php line 671:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'linkace.users' doesn't exist (SQL: select * from `users`
   where `email` = my@user.com limit 1)

In Exception.php line 18:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'linkace.users' doesn't exist

In PDOConnection.php line 78:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'linkace.users' doesn't exist

(I prefer using docker exec rather than docker-compose run, as the latter method scatters orphans around)

Kovah commented 4 years ago

Not easy as you have different instructions on different pages

As of the latest release, there is only one: https://www.linkace.org/docs/v1/setup/setup-with-docker/ Which pages do you use and reference to?

Please run the regular setup after starting the Docker containers.

Kovah commented 3 years ago

I have tested this with the latest files from the repository and the current guide available on the website. To prevent permission issues, I have set a user: "0" configuration in the Docker Compose file:

  app:
    image: linkace/linkace:latest
    restart: unless-stopped
    depends_on:
      - db
    user: "0"
    volumes:
      - linkace_app:/app
      - ./.env:/app/.env
      - ./logs:/app/storage/logs

I was able to start the application and logs are being written to the storage/logs directory, and are also available on the host.

dokbua commented 3 years ago

Good on ya updating the setup document, that is a great help. I can't tell exactly which procedures and pages I followed, I didn't write them all down, just followed what was available on the page. There is still some confusion, but the setup document makes it a bit easier. Things like, why do you need 3 different docker-compose files, 2 different nginx.conf files.

Anyway, back to the point. I cleared up everything (again). Ran the install according to your setup document "simple" version, including the user: "0" as suggested here, but it still conked out with the unwritable files errors. I really don't understand how you can have it working on your system, are you developing under windows? Any Linux system would require a valid user with appropriate rights to write files. Anyway, let's also pass on that, I just commented out the logs line in the docker-compose, and now it started the stack.

It still doesn't work though: 500 - Server Error An internal server error occured. If you are the administrator, consult the application logs for details.

As far as I can see from docker-compose logs, the problems comes down to this, if that helps:

app_1 | [php-fpm:access] 127.0.0.1 - 12/Nov/2020:21:24:13 +0000 "GET /index.php" 500 /app/public/index.php 69.826 4096 114.57%

Kovah commented 3 years ago

Did you replace the 0 for the user with the actual ID with the user running the container?

I have talked to the maintainers of the PHP Image and they said giving proper permissions to the mounted directory is they way to go as changing the user can lead to unintended side effects.

dokbua commented 3 years ago

Actually regardless of the user line given, it always will use userid 1000 - which isn't the docker user. In the end I had to chmod logs and .env 777. Not acceptable for production use, but allowed the test to continue.

Now, again importing a chrome bookmarks export file:

Something went wrong while trying to import the bookmarks. Please consult the application logs.

and in the import log:

[2020-11-18 20:46:47.549503] [info] PARSING LINE #333
[2020-11-18 20:46:47.549551] [info] PARSING LINE #334
[2020-11-18 20:46:47.549619] [info] PARSING LINE #335
[2020-11-18 20:46:47.549679] [info] File parsing ended

When checking the import file this correspond to the location of the first bookmark folder, so it seems the app don't know what to do about that. It is what it is, I guess I have to conclude that it sort of works at this time, when making allowance for the user id.

I don't really understand what you mean by changing user can have unintended side effects. Most of the docker containers I run either link no local volumes, or allow the setting through either UID/GID or PUID/PGID environment variables.

Kovah commented 3 years ago

I am sorry that I can't help you with this topic. Mounted Docker volumes are a pain, and I can only share the insights I gathered from the image maintainers.

Kovah commented 3 years ago

Based on your feedback i decided to implement a log viewer into the app and switch to Docker volumes for log storage.