Closed nonzod closed 2 years ago
I have too little info to give you answer.
For example is sourceborker/deployer-instance
installed and loaded?
If yes then you need to debug vendor/deployer-extended-database/deployer/db/config/set.php
set('db_storage_path_local', function () {
if (Configuration::getLocalHost()->getConfig()->get('db_storage_path_relative', false) == false) {
$dbStoragePathLocal = Configuration::getLocalHost()->getConfig()->get('deploy_path') . '/.dep/database/dumps';
} else {
$dbStoragePathLocal = Configuration::getLocalHost()->getConfig()->get('deploy_path') . '/'
. Configuration::getLocalHost()->getConfig()->get('db_storage_path_relative');
}
runLocally('[ -d ' . $dbStoragePathLocal . ' ] || mkdir -p ' . $dbStoragePathLocal);
return $dbStoragePathLocal;
});
Thank you for the answer. Yes is installed and loaded.
composer.json
"require-dev": {
"deployer/deployer": "^6.8",
"drupal/devel": "^4.1",
"drupal/drupal-extension": "^4.1",
"drupal/twig_xdebug": "^1.2",
"kint-php/kint": "^3.3",
"sourcebroker/deployer-extended-database": "^13.0"
}
deployer.php
namespace Deployer;
require 'recipe/drupal8.php';
new \SourceBroker\DeployerLoader\Load([
['path' => 'vendor/sourcebroker/deployer-instance/deployer'],
['path' => 'vendor/sourcebroker/deployer-extended-database/deployer'],
]);
and yes, vendor/deployer-extended-database/deployer/db/config/set.php
contains
// Returns path to store database dumps on local stage.
set('db_storage_path_local', function () {
if (Configuration::getLocalHost()->getConfig()->get('db_storage_path_relative', false) == false) {
$dbStoragePathLocal = Configuration::getLocalHost()->getConfig()->get('deploy_path') . '/.dep/database/dumps';
} else {
$dbStoragePathLocal = Configuration::getLocalHost()->getConfig()->get('deploy_path') . '/'
. Configuration::getLocalHost()->getConfig()->get('db_storage_path_relative');
}
runLocally('[ -d ' . $dbStoragePathLocal . ' ] || mkdir -p ' . $dbStoragePathLocal);
return $dbStoragePathLocal;
});
Found the problem.
Thanks to you suggestion I've noticed that Configuration::getLocalHost()
use the default_stage value.
My default_stage is 'staging', changing to 'local' everythings works.
It's not intuitive but it works.
You should not change default_stage
yourself. It is set automatically based on .env INSTANCE value!
Look on vendor/sourcebroker/deployer-instance/deployer/config/set.php
<?php
namespace Deployer;
use RuntimeException;
use SourceBroker\DeployerInstance\Env;
set('default_stage', function () {
$env = new Env();
$env->load();
$instance = $env->get('INSTANCE');
if ($instance === null) {
throw new RuntimeException(
'INSTANCE var is no set.',
1602784218
);
}
return $instance;
});
set('argument_stage', function () {
return input()->getArgument('stage');
});
Ok but this is in contrast with the official documentation:
I do not understand why is this in contrast. The default_stage
is set for you based on .env data.
Ok - I see what you mean.
In fact I never used "default_stage" in the meaning it was created for. I always do deploy with the given instance/stage.
So always "dep deploy prod" and never "dep deploy".
Without such trick most of commands would be much more complicated.
Examples:
dep db:export
would be dep db:export local
when you run it local instance and dep db:export staging
when you run it in staging instance.
dep db:pull live
would be dep db:pull live --options=target:local
when you run it local instance and dep db:pull live --options=target:staging
when you run it in staging instance.
So because I no not use "default_stage" for doing deploys then I use "default_stage" for simplifying database operations.
Ok, all clear. I think it is important to write this in the documentation.
thank you @kszymukowicz !
my config:
at
./vendor/bin/dep db:pull staging -vvv
Attempt to create the staging_path (get('staging_path')) directory locally instead of using local path (getcwd()). The .env files are set in both environments with INSTANCE="local" for localhost and INSTANCE="staging" for staging.