Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
edvordo
@edvordo
You can setup custom options .. for example:
option('MyOptionName', 'M', InputOption::VALUE_OPTIONAL, '', 334);

task('test', function () {
    echo 'MyOptionName: ' . input()->getOption('MyOptionName') . PHP_EOL;
});
and use it like this % ./vendor/bin/dep test test -vvv --MyOptionName=2222 with output
➤ Executing task test
MyOptionName: 2222
Hamael18
@Hamael18
ok thank you. I'll test tomorrow and let you know! Thanks!
Sascha Englert
@rl-saen
Thank you very much, @edvordo !
Hamael18
@Hamael18
It works very well. Thanks!
rccc
@rccc
Hello
rccc
@rccc
i'm trying to deploy a symfony4 project
i set 'env' variable like this :
set('env', [
    'APP_ENV'        =>    'prod', 
    'APP_DEBUG'        =>    false
]);
but echo $APP_DEV is empty
and the app try to load 'dev' class
Maerryham
@Maerryham
hello everyone
i have a deploy.php script i use to push to staging and production server but it always gives error at the artisan command
Maerryham
@Maerryham

<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project name
set('application', 'icashremit');

set('repository', 'https://ionec@bitbucket.org/ionecteam/icashremit-middleware-engine.git');

set('git_tty', true);

add('shared_files', ['.env']);
add('shared_dirs', ['storage']);

// Writable dirs by web server
add('writable_dirs', []);

// Hosts
host('production')
->hostname('icashremit.com')
->set('deploy_path', '/var/www/energy')
->user('root')
->port(22)
->identityFile('~/.ssh/id_rsa')
->forwardAgent(true)
->multiplexing(false)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');

host('staging')
->hostname('icashremit.com')
->set('deploy_path', '/var/www/test')
->user('root')
->port(22)
->identityFile('~/.ssh/id_rsa')
->forwardAgent(true)
->multiplexing(false)
->addSshOption('UserKnownHostsFile', '/dev/null')
->addSshOption('StrictHostKeyChecking', 'no');
// Tasks

task('vendors', function () {
run('cd {{release_path}} && composer install');
});

task('artisan:storage:link', function (){});

task('artisan:view:clear', function (){});

task('artisan:cache:clear', function (){});

task('artisan:config:cache', function (){});

task('reload:server', function () {
run('sudo /etc/init.d/nginx restart');
})->desc('Reload SERVER');

task('reload:php-fpm', function () {
run('sudo /usr/sbin/service php7.2-fpm reload');
})->desc('Reload PHP7.2 FPM');

after('deploy:failed', 'deploy:unlock');

after('deploy', 'reload:php-fpm');
after('deploy', 'reload:server');
//Here is the deployer code

Maerryham
@Maerryham
Here is the response from server

✈︎ Deploying staging on staging
✔ Executing task deploy:prepare
✔ Executing task deploy:lock
✔ Executing task deploy:release
➤ Executing task deploy:update_code
Warning: Permanently added 'icashremit.com,167.99.206.183' (ECDSA) to the list of known hosts.
Cloning into '/var/www/test/releases/1.1'...
Password for 'https://ionec@bitbucket.org':
remote: Counting objects: 1993, done.
remote: Compressing objects: 100% (1244/1244), done.
remote: Total 1993 (delta 958), reused 1451 (delta 616)
Receiving objects: 100% (1993/1993), 9.63 MiB | 6.23 MiB/s, done.
Resolving deltas: 100% (958/958), done.
Checking connectivity... done.
Connection to icashremit.com closed.
✔ Ok
✔ Executing task deploy:shared
➤ Executing task deploy:vendors
To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcD
✔ Ok
✔ Executing task deploy:writable
✔ Executing task artisan:storage:link
➤ Executing task artisan:view:cache
✔ Executing task deploy:failed
✔ Executing task deploy:unlock

In Client.php line 103:

The command "/usr/bin/php /var/www/test/releases/1.1/artisan view:cache" failed.

Exit Code: 1 (General error)

Host Name: staging

================
Warning: Permanently added 'icashremit.com,167.99.206.183' (ECDSA) to the list of known hosts.

edvordo
@edvordo
Have you tried to run view:cache locally to see whether it gives any errors?
patrickatkeylogic
@patrickatkeylogic

Hello everyone,

I can't seem to find what I need from the docs so hopefully this is just my ignorance showing. My project directory is set up in a way that has Laravel contained within a sub-directory and not at the top level. When deployer tries to run composer install it's obviously not in the right directory but I can't make out how I'm suppose to indicate this in the deploy.php file.

I've tried a few things like this:

within('{{release_path}}/server_side', function ()
{
    run('build');
});

but it results in the same problem. So how do I specify what directory Laravel resides in? Thanks in advance!

edvordo
@edvordo
I don't think this is possible with vanilla deployer tasks. You'll probably have to rewrite all the tasks add the /server_side part to everywhere (which I'd advise against doing). Why not just split the respositories?
patrickatkeylogic
@patrickatkeylogic
It's unfortunately not my project and I doubt I'll be able to split it up. I'll still do some digging but might have to find another solution. Thanks!
edvordo
@edvordo
well, alright .. do you need the other stuff from the repo apart from the laravel code?
because if not, after the project clones, you could just copy the contents from server_side a directory up and then proceed as normal
Frederick Henderson
@frederickjh
I am guessing you have seen this: https://deployer.org/docs/how-to-deploy-laravel.html
edvordo
@edvordo
@frederickjh his use case a bit special, the laravel project in his repo is in a sub folder, so that manual wont work.
patrickatkeylogic
@patrickatkeylogic
The project is basically a standard Angular project with Laravel in a server directory. I do need to run some npm tasks in the Angular project to build into the public folder.
I might have to do some copy/move magic to get this to work. Might be easier to try convincing the client to have a few hours to properly set this up :)
Maerryham
@Maerryham

@edvordo

Have you tried to run view:cache locally to see whether it gives any errors?

Yes i have. it says "There are no commands defined in the view namespace"

edvordo
@edvordo
Wait, what? How is that even possible? You get that command with laravel/framework by default.
Also, I just noticed, why are you overriding these?
task('artisan:storage:link', function (){});
task('artisan:view:clear', function (){});
task('artisan:cache:clear', function (){});
task('artisan:config:cache', function (){});
Maerryham
@Maerryham

@edvordo > Wait, what? How is that even possible? You get that command with laravel/framework by default.

sorry, i am a fresher in deploy, please guide me through

edvordo
@edvordo
Is the project you are trying to deploy is a standard laravel project?
Maerryham
@Maerryham
@edvordo Its a project built with lumen
edvordo
@edvordo
Oh, well, lumen doesn't have view I think, so yea, that command will fail. That explains the other commands overrides. You can do what you did with those and just make it do nothing.
Maerryham
@Maerryham

I have gone past that stage. I now get this error :The command "cd /var/www/test/releases/1.1 && /usr/bin/php artisan --version" failed.

Exit Code: 1 (General error)

Host Name: staging

i discovered that the composer:install command has not run yet, hence no vendor/autoload file to produce version.
How to I update my code to run composer install before the artisan commands
Maerryham
@Maerryham

I have gone past that stage. I now get this error :The command "cd /var/www/test/releases/1.1 && /usr/bin/php artisan --version" failed.

Exit Code: 1 (General error)

Host Name: staging
i discovered that the composer:install command has not run yet, hence no vendor/autoload file to produce version.
How to I update my code to run composer install before the artisan commands @edvordo

edvordo
@edvordo
the deploy task should have already done that for you .. unless you've overwritten it ..
if you did, then you need to call it in the order you need
Waqas Mehmood
@waqas-mehmood-pk

Hi All
I have a laravel project and init laravel deployer setup file.
here is my deploy.php code

<?php namespace Deployer;

require 'recipe/laravel.php';
set('ssh_multiplexing', false);

// Project name
set('application', 'my-laravel-app');

// Project repository
set('repository', 'git@gitlab.com:group-name/repo.git');
set('use_relative_symlinks', false);
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);

// Shared files/dirs between deploys 
add('shared_files', [
    '.env'
]);
add('shared_dirs', [
    'storage'
]);

// Hosts
host('host-ip')
    ->user('root')
    ->stage('production')
    ->set('branch', 'master')
    ->set('keep_releases', 2)
    ->set('deploy_path', '/var/www/{{application}}');

// Tasks

task('upload:env', function () {
    upload('.env.production', '{{deploy_path}}/shared/.env');
})->desc('Environment setup');

when I run dep deploy production it gives me the following error.

dep deploy production -vvv
➤ Executing task deploy:prepare
[host-ip[xxx.xxx.xx.xx]] > echo $0
[host-ip[xxx.xxx.xx.xx]] < bash
[host-ip[xxx.xxx.xx.xx]] > if [ ! -d /var/www/my-laravel-app ]; then mkdir -p /var/www/my-laravel-app; fi
[host-ip[xxx.xxx.xx.xx]] > if [ ! -L /var/www/my-laravel-app/current ] && [ -d /var/www/my-laravel-app/current ]; then echo 'true'; fi
[host-ip[xxx.xxx.xx.xx]] > cd /var/www/my-laravel-app && if [ ! -d .dep ]; then mkdir .dep; fi
[host-ip[xxx.xxx.xx.xx]] > cd /var/www/my-laravel-app && if [ ! -d releases ]; then mkdir releases; fi
[host-ip[xxx.xxx.xx.xx]] > cd /var/www/my-laravel-app && if [ ! -d shared ]; then mkdir shared; fi
[host-ip[xxx.xxx.xx.xx]] < ssh: connect to host host-ip[xxx.xxx.xx.xx] port 22: Connection timed out
➤ Executing task deploy:failed
• done on [host-ip[xxx.xxx.xx.xx]]
✔ Ok [0ms]

In Client.php line 103:

  [Deployer\Exception\RuntimeException (-1)]
  The command "cd /var/www/my-laravel-app && if [ ! -d shared ]; then mkdi
  r shared; fi" failed.

  Exit Code: -1 (Unknown error)

  Host Name: host-ip[xxx.xxx.xx.xx]

  ================
  ssh: connect to host host-ip[xxx.xxx.xx.xx] port 22: Connection timed out

OS: Windows 10
Terminal: Git Bash
dep ssh working fine, connects with the server.

dep ssh
bash: line 0: cd: /var/www/my-laravel-app/current: No such file or directory
root@host-ip[xxx.xxx.xx.xx]:~#

Please guide me where I make mistakes.

Lukas
@lerni
deploy:vendors doesn't respect bin/php - we can override but wouldn't it be good to include php-path?
https://github.com/deployphp/deployer/blob/master/recipe/deploy/vendors.php#L15
like run('cd {{release_path}} && {{bin/php}} {{bin/composer}} {{composer_options}}');
edvordo
@edvordo
Lukas
@lerni
mh well yes it looks like but it isn't working for me until I overwrite deploy:vendors or hack it - running 6.7.3. If I set just bin/php and run deploy:vendors composer complains about PHP reqs - it picks default 7.1 instead of 7.3 as I set.
edvordo
@edvordo
Well, I'm on 6.6.0 and it works just by setting set('bin/php', '/usr/local/php72/bin/php'); globally .. I can't try with 6.7 atm, sorry.
Lukas
@lerni
thx for coming back to this! I'll have an other look later.
Lukas
@lerni
The version didn't make a difference but it looks like bin/php isn't respected if one also sets a custom bin/composer. So I think you cannot set both separately and expect bin/php to be respected for bin/composer.
edvordo
@edvordo
Yes, that certainly is the issue. bin/composer is set for you, but if you override it you need to include the bin/php in the override yourself
gullij
@gullij
Hi all, new to both Gitter and Deployer so apologies if I break any rules in here :-)
I just took a legacy website and enclosed it in Symfony with a LegacyBridge as suggested by Symfony documentation. Took a while but now the site works fine (locally still) from within Symfony. The next step in the modernisation is to use a deployment tool and for me Deployer felt like a natural choice.
Now I ran into a potential issue, as far as I can see Deployer doesn't have a recipe for Symfony 5 ready and of course that's the version I'm using.
So, does anyone know if the symfony4 recipe works for Symfony 5?
If not, I can probably find a way to fix a new recipe but before I get into that, is someone already working on that recipe? I don't want to duplicate the work of someone that knows the ins and outs of both Deployer and Symfony 5 better than I do.
gullij
@gullij
In case anyone's interested, the symfony4 recipe seems to work fine with Symfony 5, just a little work on the server to get a few details in place.