/** * Load server list file. * @param string $file */ function serverList($file) { $serverList = Yaml::parse(file_get_contents($file)); foreach ((array) $serverList as $name => $config) { try { if (!is_array($config)) { throw new \RuntimeException(); } $da = new \Deployer\Type\DotArray($config); if ($da->hasKey('local')) { $builder = localServer($name); } else { $builder = $da->hasKey('port') ? server($name, $da['host'], $da['port']) : server($name, $da['host']); } unset($da['local']); unset($da['host']); unset($da['port']); if ($da->hasKey('identity_file')) { if ($da['identity_file'] === null) { $builder->identityFile(); } else { $builder->identityFile($da['identity_file.public_key'], $da['identity_file.private_key'], $da['identity_file.password']); } unset($da['identity_file']); } if ($da->hasKey('identity_config')) { if ($da['identity_config'] === null) { $builder->configFile(); } else { $builder->configFile($da['identity_config']); } unset($da['identity_config']); } if ($da->hasKey('forward_agent')) { $builder->forwardAgent(); unset($da['forward_agent']); } foreach (['user', 'password', 'stage', 'pem_file'] as $key) { if ($da->hasKey($key)) { $method = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))); $builder->{$method}($da[$key]); unset($da[$key]); } } // Everything else are env vars. foreach ($da->toArray() as $key => $value) { $builder->env($key, $value); } } catch (\RuntimeException $e) { throw new \RuntimeException("Error in parsing `{$file}` file."); } } }
public function setUp() { // Create App tester. $console = new Application(); $console->setAutoExit(false); $console->setCatchExceptions(false); $this->tester = new ApplicationTester($console); // Prepare Deployer $input = $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'); $output = $this->getMock('Symfony\\Component\\Console\\Output\\OutputInterface'); $this->deployer = new Deployer($console, $input, $output); // Load recipe localServer('localhost')->env('deploy_path', self::$deployPath); $this->loadRecipe(); // Init Deployer $this->deployer->addConsoleCommands(); }
* This file has been generated automatically. * Please change the configuration for correct use deploy. */ //require 'recipe/yii2-app-basic.php'; require 'recipe/common.php'; // Set configurations set('repository', 'git@github.com:mamontovdmitriy/aaaaa.git'); set('shared_files', []); set('shared_dirs', []); set('writable_dirs', ['assets']); // Configure servers //server('production', 'aaaaa.phptest.info') // ->user('root') // ->identityFile('~/.ssh/id_rsa.pub', '~/.ssh/id_rsa', '') // ->env('deploy_path', '/var/www/aaaaa'); localServer("local")->user("www-data")->env('deploy_path', '/var/www/aaaaa'); /** * Run migrations */ task('deploy:configure_db', function () { run("echo '<?php' > {{release_path}}/db.php"); run("echo 'return [' >> {{release_path}}/db.php"); run("echo \" 'class' => 'yii\\db\\Connection',\" >> {{release_path}}/db.php"); run("echo \" 'dsn' => 'mysql:host=localhost;dbname=test_dep_aaaaa',\" >> {{release_path}}/db.php"); run("echo \" 'username' => 'test',\" >> {{release_path}}/db.php"); run("echo \" 'password' => '',\" >> {{release_path}}/db.php"); run("echo \" 'charset' => 'utf8',\" >> {{release_path}}/db.php"); run("echo \"];\" >> {{release_path}}/db.php"); })->desc('Configure database connection'); /** * Run migrations
<?php require __DIR__ . '/../../recipe/common.php'; localServer('localhost'); localServer('server1'); localServer('server2'); localServer('server3')->stage('production'); localServer('server4')->stage('production'); task('test:hello', function () { writeln('Hello world!'); }); task('test:onlyForStage', function () { writeln('You should only see this for production'); })->onlyForStage('production'); task('test', ['test:hello', 'test:onlyForStage']);
<?php localServer('localhost'); localServer('server1'); localServer('server2'); task('test', function () { writeln('Hello world!'); });
<?php // All Deployer recipes are based on `recipe/common.php`. require 'recipe/symfony.php'; // Define a server for deployment. localServer('prod')->stage('production')->env('deploy_path', '/home/www/sites/oem.imagick.ru'); // Define the base path to deploy your project to. // Specify the repository from which to download your project's code. // The server needs to have git installed for this to work. // If you're not using a forward agent, then the server has to be able to clone // your project from this repository. set('repository', 'git@github.com:popov100/oem.git'); set('shared_dirs', ['var/log', 'var/session', 'var/upload']); set('writable_dirs', ['var/cache', 'var/log', 'var/session', 'var/upload']); set('writable_use_sudo', true); after('deploy:vendors', 'database:migrate'); task('deploy:chown', function () { run('chown -R popov:www-data {{release_path}}'); }); after('deploy:cache:warmup', 'deploy:chown'); task('deploy:fixtures', function () { run('php {{release_path}}/' . trim(get('bin_dir'), '/') . '/console doctrine:fixtures:load --env={{env}} --no-debug --no-interaction'); })->desc('Apply doctrine fixtures'); after('deploy:chown', 'deploy:fixtures');
protected function setUpServer() { localServer('localhost')->env('deploy_path', self::$deployPath); }
<?php // All Deployer recipes are based on `recipe/common.php`. require 'recipe/symfony.php'; /** * Define available deployment servers. */ localServer('local')->stage('local')->env('deploy_path', __DIR__ . '/../website-localhost'); server('stage', 'your.server.com', 22)->user('johndoe')->forwardAgent()->stage('staging')->env('deploy_path', '/var/www/staging.symfony3-template.com'); server('prod', 'your.server.com', 22)->user('johndoe')->forwardAgent()->stage('production')->env('deploy_path', 'production.symfony3-template.com'); /** * Deployment settings */ set('repository', 'https://github.com/danielsreichenbach/symfony3-template.git'); set('keep_releases', 3); set('shared_dirs', ['node_modules', 'vendor']); set('shared_files', ['app/config/parameters.yml']); set('writable_dirs', ['var/cache', 'var/logs']); set('assets', ['web/css', 'web/js']); /** * Task group modifications */ task('deploy', ['deploy:prepare', 'deploy:release', 'deploy:update_code', 'deploy:create_cache_dir', 'deploy:shared', 'deploy:writable', 'deploy:vendors', 'deploy:assets', 'deploy:cache:warmup', 'deploy:symlink', 'cleanup'])->desc('Deploy your project'); /** * Download and install Node JS packages */ task('deploy:npm:install', function () { run("cd {{release_path}} && npm install"); })->desc('Installing NPM vendors'); /** * Prune NodeJS packages removed from `package.json`