NextCloud: Heroku: Install: Capture Initial Config
From Gratiel's Wiki
Contents
Visit the site
If you have not visited the site, you will need to before continuing. Launch the web page to the app, but do not setup the app just yet.
SSH into App
Need to SSH into Heroku after app starts.
heroku ps:exec --app infinite-lowlands-38883
Running this command for the first time requires a dyno restart. Do you want to continue? [y/n]: y Initializing feature... done Restarting dynos... done Waiting for web.1 to start... done Establishing credentials... done Connecting to web.1 on ⬢ infinite-lowlands-38883... ~ $
Get the current Config
cd server/config cat config.php
<?php $CONFIG = array ( 'instanceid' => 'oczm2c0yitlu', );
Create a config
- Back on the development machine:
cd nextcloud-15.0.8/server/config
- Create the config file:
cat > config.php <?php $CONFIG = array ( 'instanceid' => 'oczm2c0yitlu', );
Ctrl+D
git add . git commit -m "Initializing config.php"
- Push up code changes and restart the server
git push heroku master
Run the Setup
- Running the setup, Add username, password, and PostgreSQL information.
- Setup will Fail. Error: The username is already being used
Get new config file
- Log into Heroku again
heroku ps:exec --app infinite-lowlands-38883 Establishing credentials... done Connecting to web.1 on ⬢ infinite-lowlands-38883...
- Output config file:
<?php
$CONFIG = array (
'instanceid' => 'oci1sj5gwidj',
'passwordsalt' => '2YHY53pJ19z1sQH8VLlyxQnJ+G7X/n',
'secret' => 'UWNfUzFSNDmqTLNwhtsY3FEvg8PfDND8mUfcKmBV78UQweAS',
'trusted_domains' =>
array (
0 => 'infinite-lowlands-38883.herokuapp.com',
),
'datadirectory' => '/app/server/data',
'dbtype' => 'pgsql',
'version' => '15.0.8.1',
'overwrite.cli.url' => 'http://infinite-lowlands-38883.herokuapp.com',
'dbname' => 'd8saj3o99k4kf6',
'dbhost' => 'ec2-54-225-72-238.compute-1.amazonaws.com',
'dbport' => ,
'dbtableprefix' => 'oc_',
'dbuser' => 'tvsinoicrvngaq',
'dbpassword' => 'cb6e7c80e137f4dd06011f1319e1537e81066c66ec9a527fc75980b87d71de82',
);
This step not only establishes the database and site credentials (which we could have added manually), but it sets up the: username & password, password salt, and secretkey which all are encoded into the database.
We are going to need to save these values and enter them into Heroku's Config Vars.
Now we need to modify the config.php to accept environment variables:
<?php
$CONFIG = array (
'instanceid' => 'oci1sj5gwidj',
'passwordsalt' => getenv('PASSWORD_SALT'),
'secret' => getenv('SECRET'),
'trusted_domains' =>
array (
0 => 'infinite-lowlands-38883.herokuapp.com',
),
'datadirectory' => getenv('DATA_DIRECTORY'),
'dbtype' => 'pgsql',
'version' => '15.0.8.1',
'overwrite.cli.url' => 'http://infinite-lowlands-38883.herokuapp.com',
'dbname' => getenv('DB_NAME'),
'dbhost' => getenv('DB_HOST'),
'dbport' => ,
'dbtableprefix' => 'oc_',
'dbuser' => getenv('DB_USER'),
'dbpassword' => getenv('DB_PASSWORD'),
);
Go ahead and update the config.php on your local git repo to match this. Save and commit.
git add . git commit -m "Updated config.php. Includes DB credentials, trusted site credentials, passwordsalt & secretkey. All important values are being replaced by Environment Variables."