proxmox-scripts
proxmox-scripts copied to clipboard
How can we use external mySQL database with this script?
As the title says really.
I'd like to use an already existant mySQL db, as per this method in the official docker version. How can I edit your script to allow this?
Edit: I'm trying to run npm directly in an LXC container, no Proxmox in my setup.
bump - I want this too
First method
You need to create /app/config/default.json
file and put here next enviropments:
cfg: {
database: {
'engine': 'mysql',
'host': 'Host',
'port': 'PORT',
'user': 'envMysqlUser',
'password': 'PASSWORD',
'name': 'dbName'
}
}
Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.
Second Method
Also, you can edit /app/config/production.json
and replace old vars to this vars.
Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.
Third Method
Also, you can edit /app/lib/config.js
and update following lines:
const envMysqlHost = process.env.DB_MYSQL_HOST || 'HERE HOST';
const envMysqlUser = process.env.DB_MYSQL_USER || 'HERE USER DB';
const envMysqlName = process.env.DB_MYSQL_NAME || 'HERE NAME DB';
if (envMysqlHost && envMysqlUser && envMysqlName) {
// we have enough mysql creds to go with mysql
logger.info('Using MySQL configuration');
instance = {
database: {
engine: 'mysql',
host: envMysqlHost,
port: process.env.DB_MYSQL_PORT || HERE PORT,
user: envMysqlUser,
password: process.env.DB_MYSQL_PASSWORD || 'HERE PASS',
name: envMysqlName,
},
Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.
Fourth method
You can use terminal command:
bash
export NODE_ENV='{"config": {"host":"fqdn/ip db", "port":"portdb", "user":"userdb", "name":"namedb", "password":"passdb",}}'
Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.
P.S, sorry for nekroposting, but mb this helps somebody.
Closed?
None of these methods appear to work.
Hi @YakkaDev ,
thanks for your great answer! I'm pretty sure all those methods could work. But I have to be honest, I have no clue how to rebuild frontend with yarn or npm:D Could you or anyone give me a hint?
@YakkaDev Thanks for the detailed answer, I will look at incorporating this into the install script.
Hello @YakkaDev ,
I tried method 2:
Firstly, I retrieved the SQLite3 database located at /data/database.sqlite
then converted it to .sql format and added it to my cluster.
Next, I modified the /app/config/production.json
file
I restarted the service, restarted the container. But no change, NPM doesn't pick up the changes from this file. Additionally, there's a README.md in the /app/config/
directory that states the files in this folder are not considered if we are not in development mode.
I'm looking for another solution...
I have now tested method 3. This method works for connecting to an external database.
Unfortunately, the conversion I made from SQLite3 to SQL did not work well, and I encountered a lot of errors. I tried to find the nominal structure in the source GitHub repository: https://github.com/NginxProxyManager/nginx-proxy-manager, but I couldn't find a .sql file to install a proper base for MySQL / MariaDB. Do you know if this file exists?
Thank you
So,
I installed the docker version with MariaDB of NPM by opening port 3306 on the database part. I made a dump of the initial database to create a template. I changed the engine to INNODB because I am on a Galera Cluster (doesn't work with ARIA).
And I imported this template into my cluster.
Now it works. 😅