How to use Deployer with Docker (Laradock)

倖福魔咒の 提交于 2019-12-10 10:27:11

问题


I created a fresh Digital Ocean server with Docker on it (using Laradock) and got my Laravel website working well.

Now I want to automate my deployments using Deployer.

I think my only problem is that I can't get Deployer to run docker exec -it $(docker-compose ps -q php-fpm) bash;, which is the command I successfully manually use to enter the appropriate Docker container (after using SSH to connect from my local machine to the Digital Ocean server).

When Deployer tries to run it, I get this error message:

➤ Executing task execphpfpm
[1.5.6.6] > cd /root/laradock && (pwd;)
[1.5.6.6] < /root/laradock
[1.5.6.6] > cd /root/laradock && (docker exec -it $(docker-compose ps -q php-fpm) bash;)
[1.5.6.6] < the input device is not a TTY
➤ Executing task deploy:failed
• done on [1.5.6.6]
✔ Ok [3ms]
➤ Executing task deploy:unlock
[1.5.6.6] > rm -f ~/daily/.dep/deploy.lock
• done on [1.5.6.6]
✔ Ok [188ms]

In Client.php line 99:

  [Deployer\Exception\RuntimeException (1)]
  The command "cd /root/laradock && (docker exec -it $(docker-compose ps -q php-fpm) bash;)" failed.

  Exit Code: 1 (General error)

  Host Name: 1.5.6.6

  ================
  the input device is not a TTY

Here are the relevant parts of my deploy.php:

host('1.5.6.6')
        ->user('root')
        ->identityFile('~/.ssh/id_rsa2018-07-09')
        ->forwardAgent(true)
        ->stage('production')
        ->set('deploy_path', '~/{{application}}');

before('deploy:prepare', 'execphpfpm');

task('execphpfpm', function () {
    cd('/root/laradock');
    run('pwd;');
    run('docker exec -it $(docker-compose ps -q php-fpm) bash;');
    run('pwd');
});

I've already spent a day and a half reading countless articles and trying so many different variations. E.g. replacing the -it flag with -i, or setting export COMPOSE_INTERACTIVE_NO_CLI=1 or replacing the whole docker exec command with docker-compose exec php-fpm bash;.

Nothing works. I'd appreciate any suggestions. :-)

I expect that I'm missing something fairly simple. Docker is widely used, and Deployer seems popular too. Thanks.


回答1:


You should try

docker-compose exec -T php-fpm bash;

The -T option will

Disable pseudo-tty allocation. By default docker-compose exec allocates a TTY.



来源:https://stackoverflow.com/questions/51274489/how-to-use-deployer-with-docker-laradock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!