Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official SQLite support? #71

Closed
Zottelchen opened this issue Oct 5, 2022 · 8 comments
Closed

Official SQLite support? #71

Zottelchen opened this issue Oct 5, 2022 · 8 comments

Comments

@Zottelchen
Copy link

Zottelchen commented Oct 5, 2022

Hi,

I'd like to run my idlers with a sqlite database, since for my usecase there is a very limited amount of data and another database container seems excessive. Is there a way to do this?

My current approach (using docker-compose) looks like this:

version: '3.3'
services:
    cp6:
        container_name: my_idlers
        ports:
            - '8000:8000'
        environment:
            - APP_URL=http://localhost
            - APP_ENV=local
            - APP_DEBUG=true
            - DB_CONNECTION=sqlite
            - DB_FOREIGN_KEYS=true
        image: 'ghcr.io/cp6/my-idlers:latest'
        volumes:
         - ./db:/app/database

This however throws only 500-errors, even after ... artisan migrate:fresh ... and does not print anything to stdout, so I am not sure what exactly fails.

@cp6
Copy link
Owner

cp6 commented Oct 6, 2022

Hello

I know there are others using SQLite just not sure if they are using Docker.

Can you try touch database/database.sqlite and then php artisan migrate:fresh --seed ?

@Zottelchen
Copy link
Author

Touching & migrating works without an error. Sadly, the page still returns 500 errors.

❯ docker exec my_idlers touch database/database.sqlite

~
❯ docker exec my_idlers php artisan migrate:fresh --seed

  Dropping all tables .............................................. 19ms DONE

   INFO  Preparing database.

  Creating migration table ......................................... 29ms DONE

   INFO  Running migrations.

  2014_10_12_000000_create_users_table ............................. 70ms DONE
  2014_10_12_100000_create_password_resets_table ................... 46ms DONE
  2021_02_10_122904_create_servers_table ........................... 23ms DONE
  2022_01_30_112059_create_providers_table ......................... 47ms DONE
  2022_01_30_112350_create_locations_table ......................... 49ms DONE
  2022_02_01_031629_create_os_table ................................ 42ms DONE
  2022_02_01_233932_create_domains_table ........................... 21ms DONE
  2022_02_02_005352_create_d_n_s_table ............................. 23ms DONE
  2022_02_03_035702_create_labels_table ............................ 42ms DONE
  2022_02_03_040140_create_shareds_table ........................... 23ms DONE
  2022_02_03_040152_create_resellers_table ......................... 23ms DONE
  2022_02_05_104355_create_yabs_table .............................. 49ms DONE
  2022_02_05_104551_create_disk_speed_table ........................ 26ms DONE
  2022_02_05_104919_create_network_speed_table ..................... 47ms DONE
  2022_02_05_105219_create_pricing_table ........................... 51ms DONE
  2022_02_08_010323_create_labels_assigned_table ................... 45ms DONE
  2022_02_09_032438_create_settings_table .......................... 21ms DONE
  2022_02_11_022150_create_miscs_table ............................. 22ms DONE
  2022_02_21_001233_create_ips_table ............................... 44ms DONE
  2022_03_05_125635_add_cols_to_settings ........................... 45ms DONE
  2022_03_09_022939_add_homepage_amount_cols_to_settings ........... 46ms DONE
  2022_05_09_114227_add_foreign_keys ................................ 0ms DONE
  2022_05_09_154509_add_dark_mode_setting .......................... 23ms DONE
  2022_05_15_105254_create_seedboxes_table ......................... 26ms DONE
  2022_05_29_105255_add_dash_currency_setting ...................... 24ms DONE
  2022_06_24_010658_alter_yabs_foreign_key .......................... 0ms DONE
  2022_06_24_023931_alter_yabs_foreign_key_delete ................... 0ms DONE
  2022_07_20_011250_add_columns_to_yabs_table ..................... 137ms DONE
  2022_07_20_015804_add_column_to_settings_table ................... 22ms DONE
  2022_09_22_020501_update_yabs_table ............................. 117ms DONE

   INFO  Seeding database.

  Database\Seeders\SettingsSeeder .................................... RUNNING
  Database\Seeders\SettingsSeeder .............................. 33.13 ms DONE

  Database\Seeders\ProvidersSeeder ................................... RUNNING
  Database\Seeders\ProvidersSeeder ............................. 24.33 ms DONE

  Database\Seeders\LocationsSeeder ................................... RUNNING
  Database\Seeders\LocationsSeeder ............................. 24.33 ms DONE

  Database\Seeders\OsSeeder .......................................... RUNNING
  Database\Seeders\OsSeeder .................................... 25.08 ms DONE

  Database\Seeders\LabelsSeeder ...................................... RUNNING
  Database\Seeders\LabelsSeeder ................................ 26.48 ms DONE


~ took 2s

@cp6
Copy link
Owner

cp6 commented Oct 7, 2022

Alright so from that it doesn't seem to be a database issue, is there anything in the PHP or Laravel logs?

@Zottelchen
Copy link
Author

Are they redirect to the container stdout? If so, then no.

@imlonghao
Copy link
Contributor

log location: /app/storage/logs/laravel.log

@Zottelchen
Copy link
Author

Zottelchen commented Oct 31, 2022

Sorry, that it took a while to respond😅

So, I've changed my setup a bit. It is now in a private network utilizing homeall/caddy-reverse-proxy-cloudflare.

docker-compose.yaml
version: '3.3'
services:
  cp6:
    container_name: my_idlers
    restart: unless-stopped
    labels:
      caddy: myidlers.example.org
      caddy.reverse_proxy: '{{upstreams 8000}}'
      caddy.tls.dns: cloudflare < apikey >
    env_file:
      - .env
    image: 'ghcr.io/cp6/my-idlers:latest'
    volumes:
      - './db:/app/db'
      - './logs:/app/storage/logs'
      - '.env:/app/.env'
    networks:
      - caddy
networks:
  caddy:
    external: true
.env
APP_URL=https://myidlers.example.org
APP_ENV=local
APP_DEBUG=false
DB_DATABASE=/app/db/db.sqlite
DB_CONNECTION=sqlite
DB_FOREIGN_KEYS=true
APP_KEY=base64:yadayada

My setup steps were:

  1. $ docker exec -it my_idlers ash
  2. # touch db/db.sqlite
  3. # php artisan migrate:fresh --seed
  4. # php artisan key:generate

Currently, it only works with APP_ENV=local. In production mode, it seems that, the app doesn't seem to find the APP_KEY. From the laravel logs:

[2022-10-31 23:38:18] production.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\\Encryption\\MissingAppKeyException(code: 0): No application encryption key has been specified. at /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:79)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Support/helpers.php(302): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}('')
#1 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(81): tap('', Object(Closure))
#2 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(60): Illuminate\\Encryption\\EncryptionServiceProvider->key(Array)
#3 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(32): Illuminate\\Encryption\\EncryptionServiceProvider->parseKey(Array)
#4 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(871): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#5 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\\Container\\Container->build(Object(Closure))
#6 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(860): Illuminate\\Container\\Container->resolve('encrypter', Array, true)
#7 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve('encrypter', Array)
#8 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(845): Illuminate\\Container\\Container->make('encrypter', Array)
#9 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(1029): Illuminate\\Foundation\\Application->make('encrypter')
#10 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(945): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter))
#11 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(906): Illuminate\\Container\\Container->resolveDependencies(Array)
#12 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#13 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(860): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#14 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#15 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(845): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#16 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(169): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#17 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#19 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#20 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#21 /app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#22 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#23 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#24 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#30 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#31 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#34 /app/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#35 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#36 /app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#37 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(164): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#40 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(133): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#41 /app/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#42 /app/server.php(21): require_once('/app/public/ind...')
#43 {main}
"} 
[2022-10-31 23:38:18] production.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\\Encryption\\MissingAppKeyException(code: 0): No application encryption key has been specified. at /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:79)
[stacktrace]
#0 /app/vendor/laravel/framework/src/Illuminate/Support/helpers.php(302): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}('')
#1 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(81): tap('', Object(Closure))
#2 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(60): Illuminate\\Encryption\\EncryptionServiceProvider->key(Array)
#3 /app/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(32): Illuminate\\Encryption\\EncryptionServiceProvider->parseKey(Array)
#4 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(871): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#5 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\\Container\\Container->build(Object(Closure))
#6 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(860): Illuminate\\Container\\Container->resolve('encrypter', Array, true)
#7 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve('encrypter', Array)
#8 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(845): Illuminate\\Container\\Container->make('encrypter', Array)
#9 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(1029): Illuminate\\Foundation\\Application->make('encrypter')
#10 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(945): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter))
#11 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(906): Illuminate\\Container\\Container->resolveDependencies(Array)
#12 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#13 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(860): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array, true)
#14 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve('App\\\\Http\\\\Middle...', Array)
#15 /app/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(845): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#16 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(238): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#17 /app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(202): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#18 /app/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#19 /app/server.php(21): require_once('/app/public/ind...')
#20 {main}
"} 

For APP_ENV=local it seems, that once I've tried to add another provider it broke down. It threw error 419 ("Page expired") & redirected to the login. When trying to log in again, it throws error 419 again. There are no docker logs and nothing new in the laravel logs.

@cp6
Copy link
Owner

cp6 commented Nov 10, 2022

Thanks for the logs. Seeing as though you have run php artisan key:generate

Perhaps running php artisan config:cache might be worth a try and then serve: php artisan serve

These are the commands that come up as solutions for "No application encryption key has been specified" in production

@Zottelchen
Copy link
Author

Zottelchen commented Nov 11, 2022

Changing the container to APP_ENV=production and running docker exec -it my_idlers php artisan config:cache seems to work.👍️ The only remaining problem is, that that has to be done each container start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants