Install with Docker Compose : problem to connect/use database.sqlite
Draky50110 opened this issue · comments
Version
5.0.3 ?
Details & Steps to reproduce
Hello.
I tried to install with Docker Compose.
I set my own path to "/2fauth" and same for DB Host.
But here is the result :
`Running version latest commit 35f2f1d built on 2024-01-19T14:54:35Z
supervisord version: v0.6.8
PHP 8.1.22 (fpm-fcgi) (built: Aug 3 2023 23:11:21)
nginx version: nginx/1.22.1
In Connection.php line 822:
Database file at path [/srv/dev-disk-by-XXX/2fauth/database.sqlite] does not exist. Ensure this is an
absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_key
s = ON;)
In SQLiteConnector.php line 34:
Database file at path [/srv/dev-disk-by-XXX/2fauth/database.sqlite] does not exist. Ensure this is an
absolute path to the database.
`
I created manually 2fauth and chown/chmod it with 1000:1000 and 700.
It creates storage dir and and empty database.slite file in 2fauth dir... but can't access it later ?
Expectation
Connect to SQLite database.
Error & Logs
[2024-02-19 10:32:30] local.ERROR: Database file at path [/srv/dev-disk-by-XXX/2fauth/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): Database file at path [/srv/dev-disk-by-uuid-dfc61792-5a96-41c4-a9ba-df4df2d8da4e/DOWNLOADS/2fauth/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;) at /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php:822)
[stacktrace]
#0 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(776): Illuminate\\Database\\Connection->runQueryCallback()
#1 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(581): Illuminate\\Database\\Connection->run()
#2 /srv/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(511): Illuminate\\Database\\Connection->statement()
#3 /srv/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php(36): Illuminate\\Database\\Schema\\Builder->enableForeignKeyConstraints()
#4 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(272): Illuminate\\Database\\SQLiteConnection->__construct()
#5 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(76): Illuminate\\Database\\Connectors\\ConnectionFactory->createConnection()
#6 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(50): Illuminate\\Database\\Connectors\\ConnectionFactory->createSingleConnection()
#7 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(152): Illuminate\\Database\\Connectors\\ConnectionFactory->make()
#8 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(101): Illuminate\\Database\\DatabaseManager->makeConnection()
#9 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(74): Illuminate\\Database\\DatabaseManager->connection()
#10 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(908): Illuminate\\Database\\DatabaseServiceProvider->Illuminate\\Database\\{closure}()
#11 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\\Container\\Container->build()
#12 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(957): Illuminate\\Container\\Container->resolve()
#13 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\\Foundation\\Application->resolve()
#14 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(942): Illuminate\\Container\\Container->make()
#15 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(1454): Illuminate\\Foundation\\Application->make()
#16 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(240): Illuminate\\Container\\Container->offsetGet()
#17 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance()
#18 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(349): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#19 /srv/app/Providers/AppServiceProvider.php(36): Illuminate\\Support\\Facades\\Facade::__callStatic()
#20 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Providers\\AppServiceProvider->boot()
#21 /srv/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#22 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#23 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#24 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call()
#25 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1030): Illuminate\\Container\\Container->call()
#26 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1011): Illuminate\\Foundation\\Application->bootProvider()
#27 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}()
#28 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1012): array_walk()
#29 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#30 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(263): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap()
#31 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(447): Illuminate\\Foundation\\Application->bootstrapWith()
#32 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(199): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#33 /srv/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#34 {main}
[previous exception] [object] (Illuminate\\Database\\SQLiteDatabaseDoesNotExistException(code: 0): Database file at path [/srv/dev-disk-by-XXX/2fauth/database.sqlite] does not exist. Ensure this is an absolute path to the database. at /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:34)
[stacktrace]
#0 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(221): Illuminate\\Database\\Connectors\\SQLiteConnector->connect()
#1 [internal function]: Illuminate\\Database\\Connectors\\ConnectionFactory->Illuminate\\Database\\Connectors\\{closure}()
#2 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(1319): call_user_func()
#3 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(574): Illuminate\\Database\\Connection->getPdo()
#4 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(809): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}()
#5 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(776): Illuminate\\Database\\Connection->runQueryCallback()
#6 /srv/vendor/laravel/framework/src/Illuminate/Database/Connection.php(581): Illuminate\\Database\\Connection->run()
#7 /srv/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(511): Illuminate\\Database\\Connection->statement()
#8 /srv/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php(36): Illuminate\\Database\\Schema\\Builder->enableForeignKeyConstraints()
#9 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(272): Illuminate\\Database\\SQLiteConnection->__construct()
#10 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(76): Illuminate\\Database\\Connectors\\ConnectionFactory->createConnection()
#11 /srv/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(50): Illuminate\\Database\\Connectors\\ConnectionFactory->createSingleConnection()
#12 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(152): Illuminate\\Database\\Connectors\\ConnectionFactory->make()
#13 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(101): Illuminate\\Database\\DatabaseManager->makeConnection()
#14 /srv/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php(74): Illuminate\\Database\\DatabaseManager->connection()
#15 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(908): Illuminate\\Database\\DatabaseServiceProvider->Illuminate\\Database\\{closure}()
#16 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\\Container\\Container->build()
#17 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(957): Illuminate\\Container\\Container->resolve()
#18 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\\Foundation\\Application->resolve()
#19 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(942): Illuminate\\Container\\Container->make()
#20 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(1454): Illuminate\\Foundation\\Application->make()
#21 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(240): Illuminate\\Container\\Container->offsetGet()
#22 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance()
#23 /srv/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(349): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#24 /srv/app/Providers/AppServiceProvider.php(36): Illuminate\\Support\\Facades\\Facade::__callStatic()
#25 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\\Providers\\AppServiceProvider->boot()
#26 /srv/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#27 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#28 /srv/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#29 /srv/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call()
#30 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1030): Illuminate\\Container\\Container->call()
#31 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1011): Illuminate\\Foundation\\Application->bootProvider()
#32 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}()
#33 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1012): array_walk()
#34 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#35 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(263): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap()
#36 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(447): Illuminate\\Foundation\\Application->bootstrapWith()
#37 /srv/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(199): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#38 /srv/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#39 {main}
"}
Execution environment
No response
Containerization
- Docker
Additional information
No response
This seems similar to #192
Custom DB_DATABASE path is not supported, this is something I need to change. For now you have to stick to /2fauth/database.sqlite
. But you can bind this folder to the host folder of your choice with the volumes
directive of the docker-compose file:
services:
2fauth:
image: 2fauth/2fauth
container_name: 2fauth
volumes:
- /path/to/host/folder/of/your/choice:/2fauth
- ...
Ok, all ok and I changed my compose file to :
volumes:
- /srv/dev-disk-by-XXX/2fauth:/2fauth
- /srv/dev-disk-by-XXX/2fauth/database:/srv/database
2fauth and 2fauth/database folders needed to be created first and chown/chmod before deploying stack.
Logs are showing database creation and connection.
Still need to find why going to IP:8000 gives a "server error" in JSON format though...
Only /srv/dev-disk-by-XXX/2fauth:/2fauth
is needed.
/srv/database
(in the container) contains a symlink to /2fauth/database.sqlite
(as well as the storage
symlink pointing to /2fauth/storage
).
What is the reason you mounted srv/database
?
Mmmm can't remember.
Will retry without the second mounting point.
All correctly mounted and accessed : had to create base dir and chmod 1000:1000 + chmod 700 before pulling container...