Search code examples
symfonydeploymentsymfony4ovh

Hosting Symfony 4 app with EasyDeployBundle on server without /usr/local/bin/composer


For a Symfony 4 app I have chosen a Web Cloud plan from the hosting provider OVH.

For the deployment I have decided to use the EasyDeployBundle which looks very promising. This is my config file:

<?php

use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;

return new class extends DefaultDeployer
{
    public function configure()
    {
        return $this->getConfigBuilder()
            ->server('ovh')
            ->deployDir('directory/path/at/server')
            ->repositoryUrl('git@github.com:foo/bar.git')
            ->repositoryBranch('master')
        ;
    }
}

I have .ssh/config file with the following entry:

Host ovh
    Hostname sshcloud.foobar.hosting.ovh.net
    Port 12345
    User foobar

Note: all values are dummies, just for illustrational purposes.

When I run:

php bin/console deploy --dry-run -v

everything goes fine, but when I actually try to deploy I get the following error:

The command "ssh ovh 'which /usr/local/bin/composer'" failed.

The problem is that I have no write-access to the directory /usr/local/bin/ on the server. The composer.phar is in my home directory and I can't move it to the provisioned destination.

Is there any possibility to tell EasyDeployBundle to look for composer in another directory?


Solution

  • I should really read the manuals, in particular when I'm linking them in my question.

    There is a method remoteComposerBinaryPath that accepts custom path to composer. I have amended the method configure like this:

    public function configure()
    {
        return $this->getConfigBuilder()
            ->server('ovh')
            ->deployDir('directory/path/at/server')
            ->repositoryUrl('git@github.com:foo/bar.git')
            ->repositoryBranch('master')
            ->remoteComposerBinaryPath('composer.phar')
        ;
    }

    On the server I created .bashrc in my home folder and added the line:

    export PATH=$PATH:/home/foobar
    

    and now the deployment is passing this hurdle.

    I have now another problem, but at least this one is solved and maybe the answer can help other people too.