Plesk docker extension install

I have installed invoiceninja via the plesk docker extension however I can’t really find any information on how I need to set it up.
When I ran it after the first install the error came up regarding sql connection, so I looked up how to add varibles to the docker container via DB_HOST etc.

This solved the connection issue, however now i get the error " SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
ation_schema.tables where table_schema = InvoiceNinja and table_name = acco
unts and table_type = ‘BASE TABLE’) "

Which i am guessing means that the system does NOT like the fact that my database is empty. I don’t even know where to begin to address this issue. I would like to complete the set up via plesk as i am barely keeping it together on plesk so wouldnt have a chance via terminal.

Hi,

From the error it looks like the database migrations need to be run, the command is php artisan migrate.

How do I run this command for a docker container? There doesn’t seem to be any option to run commands from plesk docker extension.

Here are two things to try using the browser.

  • Directly access the setup page using /setup

  • Run the update using /update?secret=

the docker container will not run with this error. After showing the error the docker container stops, so there is no way to access /setup

@david any thoughts?

Sorry for uploading this long bit of code but maybe it will be useful.

I added the DB_HOST, DB_USERNAME and DB_PASSWORD and left DB name blank i got error message 'unknown database ‘ninja’

So i created an empty database called ninja with the above user and then the docker ran with the fillowing info:
(you can see the first error at the beginning and then result after creating the empty db called ninja.

2022-09-20T16:16:31Z [INFO] [Entrypoint]: Initialising Invoice Ninja...

   INFO  Configuration cached successfully.  


   INFO  Caching the framework bootstrap files.  

  config ........................................................... 43ms DONE
  routes ........................................................... 92ms DONE


In Connection.php line 759:
                                                                               
  SQLSTATE[HY000] [1049] Unknown database 'ninja' (SQL: select * from informa  
  tion_schema.tables where table_schema = ninja and table_name = accounts and  
   table_type = 'BASE TABLE')                                                  
                                                                               

In Connector.php line 70:
                                                   
  SQLSTATE[HY000] [1049] Unknown database 'ninja'  
                                                   

2022-09-20T16:20:29Z [INFO] [Entrypoint]: Initialising Invoice Ninja...

   INFO  Configuration cached successfully.  


   INFO  Caching the framework bootstrap files.  

  config ........................................................... 68ms DONE
  routes .......................................................... 142ms DONE


   INFO  Preparing database.  

  Creating migration table ......................................... 42ms DONE

   INFO  Loading stored database schemas.  

  database/schema/mysql-schema.dump ............................. 1,733ms DONE

   INFO  Running migrations.  

  2022_04_14_121548_forte_payment_gateway .......................... 36ms DONE
  2022_05_18_162152_create_scheduled_jobs_table .................... 21ms DONE
  2022_05_18_162443_create_schedulers_table ......................... 8ms DONE
  2022_05_28_234651_create_purchase_orders_table .................. 125ms DONE
  2022_05_30_181109_drop_scheduled_jobs_table ....................... 6ms DONE
  2022_05_30_184320_add_job_related_fields_to_schedulers_table ..... 20ms DONE
  2022_05_31_101504_inventory_management_schema .................... 44ms DONE
  2022_06_01_215859_set_recurring_client_timestamp ................. 36ms DONE
  2022_06_01_224339_create_purchase_order_invitations_table ..... 1,179ms DONE
  2022_06_10_030503_set_account_flag_for_react ..................... 12ms DONE
  2022_06_16_025156_add_react_switching_flag ........................ 9ms DONE
  2022_06_17_082627_change_refresh_token_column_size ............... 45ms DONE
  2022_06_21_104350_fixes_for_description_in_pdf_designs ............ 2ms DONE
  2022_06_22_090547_set_oauth_expiry_column ......................... 9ms DONE
  2022_06_24_141018_upgrade_failed_jobs_table ...................... 22ms DONE
  2022_06_30_000126_add_flag_to_accounts_table ..................... 13ms DONE
  2022_07_06_080127_add_purchase_order_to_expense .................. 90ms DONE
  2022_07_09_235510_add_index_to_payment_hash ..................... 104ms DONE
  2022_07_18_033756_fixes_for_date_formats_table_react .............. 1ms DONE
  2022_07_21_023805_add_hebrew_language ............................. 8ms DONE
  2022_07_26_091216_add_sms_verification_to_hosted_account ......... 36ms DONE
  2022_07_28_232340_enabled_expense_tax_rates_to_companies_table ... 12ms DONE
  2022_07_29_091235_correction_for_companies_table_types ........... 51ms DONE
  2022_08_11_011534_licenses_table_for_self_host .................... 9ms DONE
  2022_08_24_215917_invoice_task_project_companies_table ............ 9ms DONE
  2022_08_26_232500_add_email_status_column_to_purchase_order_invitations_table  9ms DONE
  2022_08_28_210111_add_index_to_payments_table .................... 64ms DONE
  2022_09_05_024719_update_designs_for_tech_template ................ 3ms DONE
  2022_09_07_101731_add_reporting_option_to_companies_table ........ 11ms DONE


2022-09-20T16:20:36Z [INFO] [Entrypoint]: /usr/local/bin/docker-entrypoint: running /docker-entrypoint-init.d/10-init-in.sh

   INFO  Seeding database.  

Running DatabaseSeeder
  Database\Seeders\ConstantsSeeder ................................... RUNNING  
  Database\Seeders\ConstantsSeeder ............................ 164.70 ms DONE  

  Database\Seeders\PaymentLibrariesSeeder ............................ RUNNING  
  Database\Seeders\PaymentLibrariesSeeder ..................... 221.93 ms DONE  

  Database\Seeders\BanksSeeder ....................................... RUNNING  
  Database\Seeders\BanksSeeder ................................ 757.53 ms DONE  

  Database\Seeders\CurrenciesSeeder .................................. RUNNING  
  Database\Seeders\CurrenciesSeeder ........................... 202.30 ms DONE  

  Database\Seeders\LanguageSeeder .................................... RUNNING  
  Database\Seeders\LanguageSeeder .............................. 58.95 ms DONE  

  Database\Seeders\CountriesSeeder ................................... RUNNING  
  Database\Seeders\CountriesSeeder ............................ 588.80 ms DONE  

  Database\Seeders\IndustrySeeder .................................... RUNNING  
  Database\Seeders\IndustrySeeder .............................. 55.61 ms DONE  

  Database\Seeders\PaymentTypesSeeder ................................ RUNNING  
  Database\Seeders\PaymentTypesSeeder .......................... 51.96 ms DONE  

  Database\Seeders\GatewayTypesSeeder ................................ RUNNING  
  Database\Seeders\GatewayTypesSeeder .......................... 23.95 ms DONE  

  Database\Seeders\DateFormatsSeeder ................................. RUNNING  
  Database\Seeders\DateFormatsSeeder ........................... 46.69 ms DONE  

  Database\Seeders\DesignSeeder ...................................... RUNNING  
  Database\Seeders\DesignSeeder ............................... 104.41 ms DONE  

Tue, 20 Sep 2022 16:20:40 +0000 Create Single Account...

2022-09-20 16:20:42,027 WARN For [program:php-fpm], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored
2022-09-20 16:20:42,027 WARN For [program:scheduler], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored
2022-09-20 16:20:42,027 WARN For [program:queue-worker], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored
2022-09-20 16:20:42,027 WARN For [program:queue-worker], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored
2022-09-20 16:20:42,033 INFO supervisord started with pid 1
2022-09-20 16:20:43,037 INFO spawned: 'shutdown' with pid 88
2022-09-20 16:20:43,041 INFO spawned: 'php-fpm' with pid 89
2022-09-20 16:20:43,046 INFO spawned: 'queue-worker_00' with pid 90
2022-09-20 16:20:43,050 INFO spawned: 'queue-worker_01' with pid 91
2022-09-20 16:20:43,055 INFO spawned: 'scheduler' with pid 92
READY
[20-Sep-2022 16:20:43] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[20-Sep-2022 16:20:43] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[20-Sep-2022 16:20:43] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[20-Sep-2022 16:20:43] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[20-Sep-2022 16:20:43] NOTICE: fpm is running, pid 89
[20-Sep-2022 16:20:43] NOTICE: ready to handle connections

   INFO  Running schedule tasks every minute.  


   INFO  Processing jobs from the [default] queue.  


   INFO  Processing jobs from the [default] queue.  

2022-09-20 16:20:44,922 INFO success: shutdown entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-20 16:20:44,923 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-20 16:20:44,923 INFO success: queue-worker_00 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-20 16:20:44,923 INFO success: queue-worker_01 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-20 16:20:44,923 INFO success: scheduler entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
   INFO  No scheduled commands are ready to run.  

   INFO  No scheduled commands are ready to run.  

   INFO  No scheduled commands are ready to run.  

2022-09-20T16:16:33Z [ERROR] [Entrypoint]: Error connecting to DB

I now open the created empty database and it is full of the info from the above run scripts.
The docker container now stays running and does not autoclose.

When i open the url to the docker I now get ‘502 Bad Gateway’

Error in the plesk error log say:

“124173#0: *894 upstream prematurely closed connection while reading response header from upstream”
and
“502 GET /favicon.ico HTTP/2.0”

and “GET / HTTP/2.0”

sorry not sure on this but the last line tells the story:

2022-09-20T16:16:33Z [ERROR] [Entrypoint]: Error connecting to DB

the DB issue is now resolved. Creating an empty db with the name ninja and adding user, pass and host in the variables allowed the process to continue.

The issue is now the 502 bad gateway.

Error in the plesk error log say:

“124173#0: *894 upstream prematurely closed connection while reading response header from upstream”
and
“502 GET /favicon.ico HTTP/2.0”

and “GET / HTTP/2.0”

If not error solvable, is there a recommended guide to deploying invoiceninja via the plesk docker extension?

AT the moment there is no formal/informal guide. I just find invoiceninja in the catelogue and hit run.
Do the docker proxy and that is it.

I have had to move forward stage by stage via trial and error.

I tried a different image. Truecharts/invoiceninja-v5
I followed the same steps. Set up the DB_LOCALHOST, USERNAME, PASSWORD, then got the error
'unknown database ‘forge’
so i created an empty database ‘forge’ and the process kicked off just as before.

This time it all loaded fine. I have got to the initial log in page. There was no set-up or install page. Direct to log in page.

I have no log in details.

I have opened the database, there is a user admin@example.com i have tried changing the password and logging in. Nope.
I added another user, tried that email and password. Nope.

I just get the error:
“401: These credentials do not match our records”

I tried password reset and it said ‘a password recovery email has been sent’ but I don’t get anything in my email.
I am just a little frustrated with this whole system at the moment!

OK, so after some MORE digging, I added the variables below to the container settings in plesk:

MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=‘@gmail.com
MAIL_FROM_NAME=‘’

Then tried password reset. This worked.

However when I try to log in, I get the error
“400: User found, but not attached to any companies, please see your administrator”

Is there a default admin account or where can i create one via database?

aaaand finally, I changed the ‘id’ of the account I created to ‘1’ and then reset the ;password and logged in.

I now have admin access AND it is all working. So far.

Thanks all. :slight_smile:

ALTHOUGH! i did a health check and there are two issues that are highlighted, php memory limit is too low and queue not enabled.

I mean, i JUST about managed to get smtp setup and admin account access. I don’t think, unless it is clear cut, I am going to be diving in to try and fix these…

I celebrated too soon.
I get emails about new log-ins, i get forgot email passwords but i don’t get any emails when I send invoices.

I’m really sorry i don’t just spend some time looking in to this before posting here, but the solution here seemed to be adding the correct SEND_FROM_ADDRESS variable to the docker container.

After that everything was peachy.

2 Likes

Glad to hear it’s working, thanks for sharing the solution!