rocketeer icon indicating copy to clipboard operation
rocketeer copied to clipboard

deploying one app to multiple server/server folders with different settings of deployment

Open bakroistvan opened this issue 9 years ago • 10 comments

Hi

I made an app and many "customer" using it. So I want to deploy one app folder to many folder on the server, than install dependencies with composer, and copy config files.

Is there any opportunity to:

  • have multiple server connections (YES: in config.php via connections array)
  • have multiple definition of remote deployment (multiple remote.php?? )?
  • have multiple hooks.php
  • match the connections to the {hooks.php and remote.php} config?

Example Customers = {anna, bob, ...} Servers = {server1, server2, ...}

Deployment for anna on server1 via remote1.php with hooks1.php Deployment for bob on server2 via remote2.php with hooks2.php ... and so on

Thanks Steve

bakroistvan avatar Mar 13 '15 20:03 bakroistvan

It seems what you're looking for is contextual configuration, check around the bottom of this section http://rocketeer.autopergamene.eu/#/docs/docs/II-Concepts/Connections-and-Stages

Anahkiasen avatar Mar 13 '15 21:03 Anahkiasen

thanks man

i did it, my only problem is that during I deploy 3 staging for example: .rocketeer/connections/dev/hooks.php does not overwrite the original hooks.php

config.php

'on'               => [

        // Stages configurations
        'stages'      => [],
        // Connections configuration
        'connections' => [],

    ],

stages.php

'stages'  => ['dev', 'prod'],

hooks.php

<?php

return [

    // Tasks
    //
    // Here you can define in the `before` and `after` array, Tasks to execute
    // before or after the core Rocketeer Tasks. You can either put a simple command,
    // a closure which receives a $task object, or the name of a class extending
    // the Rocketeer\Abstracts\AbstractTask class
    //
    // In the `custom` array you can list custom Tasks classes to be added
    // to Rocketeer. Those will then be available in the command line
    // with all the other tasks
    //////////////////////////////////////////////////////////////////////

    // Tasks to execute before the core Rocketeer Tasks
    'before' => [
        'setup'   => [],
        'deploy'  => [],
        'cleanup' => [],
    ],

    // Tasks to execute after the core Rocketeer Tasks
    'after'  => [
        'setup'   => [],
        'deploy'  => [],
        'cleanup' => [],
    ],

    // Custom Tasks to register with Rocketeer
    'custom' => [
        'conf:debug' => 'MyTasks\ConfDebug',
        'conf:release' => 'MyTasks\ConfRelease'
    ],

];

.rocketeer/connections/dev/hooks.php

<?php

return [

    // Tasks
    //
    // Here you can define in the `before` and `after` array, Tasks to execute
    // before or after the core Rocketeer Tasks. You can either put a simple command,
    // a closure which receives a $task object, or the name of a class extending
    // the Rocketeer\Abstracts\AbstractTask class
    //
    // In the `custom` array you can list custom Tasks classes to be added
    // to Rocketeer. Those will then be available in the command line
    // with all the other tasks
    //////////////////////////////////////////////////////////////////////

    // Tasks to execute before the core Rocketeer Tasks
    'before' => [
        'setup'   => [],
        'deploy'  => [],
        'cleanup' => [],
    ],

    // Tasks to execute after the core Rocketeer Tasks
    'after'  => [
        'setup'   => [],
        'deploy'  => [
            function($task){
                $task->upload(base_path().'/configs/database.php', $task->releasesManager->getCurrentReleasePath().'/app/Config/database.php');
                $task->setPermissions('/app/Config/database.php');
            }
        ],
        'cleanup' => [],
    ],

    // Custom Tasks to register with Rocketeer
    'custom' => [
        'conf:debug' => 'MyTasks\ConfDebug',
        'conf:release' => 'MyTasks\ConfRelease'
    ],

];

bakroistvan avatar Mar 13 '15 23:03 bakroistvan

Hi!

Has this been solved already? I'm facing the same problem on my Windows machine, whereas my partner on Linux does not have this problem.

The hooks.php has been defined in the right stage folder, but the 'general' hooks.php is loaded.

Thanks!

Pim

pvdbroek avatar Nov 02 '15 12:11 pvdbroek

Hi

Delete the hooks.php. Create stages/my_stage_server_name/hooks.php.

Edit the stages.php file like this:

<?php
return [
    'stages'  => ['my_stage_server_name', 'my_stage_server_name2'],

    'default' => ['my_stage_server_name'],
];

bakroistvan avatar Nov 02 '15 13:11 bakroistvan

Thanks for your very quick response!

I deleded the hooks.php, but it still won't run the hooks in my /stages/staging/hooks.php

My files contain:

.rocketeer/stages.php

<?php return array(
    'stages' => array('staging', 'production'),
    'default' => 'staging',
);

.rocketeer/stages/staging/hooks.php:

<?php return array(

    // Tasks to execute before the core Rocketeer Tasks
    'before' => array(
        'setup'   => array(),
        'deploy'  => array(
            function ($task) {
...
        }),
        'cleanup' => array(),
    ),

    // Tasks to execute after the core Rocketeer Tasks
    'after' => array(
        'setup'   => array(),
        'deploy'  => array(
            function ($task) {

....

            }),
        'cleanup' => array(
            function ($task) {
...

            }),
    ),

    // Custom Tasks to register with Rocketeer
    'custom' => array(),

);

Any idea's how to get it to work?

Best regards,

Pim

pvdbroek avatar Nov 02 '15 13:11 pvdbroek

Yes that's the one :)

.rocketeer/stages/staging/hooks.php

pvdbroek avatar Nov 02 '15 13:11 pvdbroek

this is my .rocketeer folder

http://www.pastefile.com/EqANGl

bakroistvan avatar Nov 02 '15 14:11 bakroistvan

Thanks @bakroistvan . I have the same setup as you have, but somehow it still does not work.

Do you use windows or linux?

This setup DOES work on linux, just not in windows :(

pvdbroek avatar Nov 02 '15 14:11 pvdbroek

Ohh I am using windows.

Didi you tried with Cygwin?

bakroistvan avatar Nov 02 '15 14:11 bakroistvan

That gives me hope :)

I did not try Cygwin, and knowing that you use it on windows as well, makes me think like I should be able to get it working... I just don't understand why it does not work.

pvdbroek avatar Nov 02 '15 15:11 pvdbroek