deployer icon indicating copy to clipboard operation
deployer copied to clipboard

How to deploy a project in laradock ?

Open kisexu opened this issue 8 years ago • 26 comments

Q A
Issue Type Question
Deployer Version N/A
Local Machine OS mac
Remote Machine OS ubuntu (laradock)

Description

I want to deploy a laravel project in laradock. I can update code files to server.But how to run php command in laradock ?Is there a configuration to run php command in laradock ?Thank you!

kisexu avatar Jun 19 '18 12:06 kisexu

I never worked with laradock, can't tell.

antonmedv avatar Jun 19 '18 13:06 antonmedv

@antonmedv Can I run some commands after ssh host? I need run command "docker-compose exec workspace bash". Then I can run command other tasks in docker container.

I try to add a task:

task('deploy:intodocker', function () {
    run("cd /home/www/laradock && docker-compose exec workspace bash");
})
before('deploy:prepare', 'deploy:intodocker');

But I failed.

kisexu avatar Jun 19 '18 17:06 kisexu

You need to connect to laradock by ssh.

antonmedv avatar Jun 20 '18 01:06 antonmedv

@kisexu @antonmedv I have the same problem. I am new to Laradock and Deployer (both look so cool!), and I installed them yesterday, and where I'm stuck is a couple places:

  1. I keep getting this warning To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcD even though I'm pretty sure I've installed the zip extension in the appropriate containers.
  2. When Deployer reaches the vendors.php script, I get this error:
In Client.php line 99:

  [Deployer\Exception\RuntimeException (1)]
  The command "command -v 'php'" failed.

  Exit Code: 1 (General error)

So then I tried overriding with:

task('deploy:vendors', function () {
    run('cd ~/laradock && docker-compose exec workspace bash');
    if (!commandExist('unzip')) {
        //writeln('<comment>To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcD</comment>');
    }
    //run('cd {{release_path}} && {{bin/composer}} {{composer_options}}');
    run('cd /var/www/myproject/release && {{bin/composer}} {{composer_options}}');
});

(sort of like @kisexu ) but now I'm stuck with this error:

[Deployer\Exception\RuntimeException (255)]
  The command "cd ~/laradock && docker-compose exec workspace bash" failed.

  Exit Code: 255 (Unknown error)

I'm curious if there is a way to get Deployer working with Docker.

ryancwalsh avatar Jul 10 '18 11:07 ryancwalsh

The unzip extension you can add to your PHP worker. As for the other errrors, I would check logs in workspace.

jasperf avatar Jul 10 '18 12:07 jasperf

@kisexu Did you ever get Deployer to work with Docker?

I posted a question here: https://stackoverflow.com/questions/51274489/how-to-use-deployer-with-docker-laradock

@jasperf Yes, I think the zip extension is already installed in my php-fpm Docker container, but the problem is that Deployer won't switch into that container (as you can see in my recent StackOverflow question).

I'm super confused about why run('cd /root/laradock && (docker exec -i $(docker-compose ps -q php-fpm) bash;)'); would be completely ignored by Deployer. It's as if nothing happens. I've used Xdebug to step through the code and see that it successfully runs proc_open at https://github.com/symfony/process/blob/v4.1.0/Process.php#L304, but in reality, Deployer stays outside of the Docker container that it would have entered if docker exec -i $(docker-compose ps -q php-fpm) bash actually had been run.

I'd appreciate any ideas, @antonmedv . Your tool is so impressive! I hope I can get it to work for me. This is all I've been working on for almost 3 days now.

More details about what I've tried are at: https://stackoverflow.com/questions/51274489/how-to-use-deployer-with-docker-laradock

Thanks!

ryancwalsh avatar Jul 11 '18 14:07 ryancwalsh

@ryancwalsh laradock created only for local development?

antonmedv avatar Jul 11 '18 15:07 antonmedv

@antonmedv I'm almost positive that it doesn't matter how the Docker containers were created (Laradock or otherwise).

(If I had created Docker containers from scratch without Laradock, I'd face the same problem right now.)

So this question could be renamed to "How to use Deployer with Docker containers?"

ryancwalsh avatar Jul 11 '18 15:07 ryancwalsh

How to use Deployer with Docker containers?

Good question. :) Now not. Will be in v7.

antonmedv avatar Jul 11 '18 17:07 antonmedv

@antonmedv Thanks for your response! I look forward to v7.

ryancwalsh avatar Jul 11 '18 17:07 ryancwalsh

+1

Also waiting for docker support. ASAP :) Cause I've spent 3 days trying to make it work with docker. Nope. And between docker and deployer we have chosen docker.

Please, update your package to make it possible to use it with latest technologies :)

Denis4yk avatar Jul 26 '18 21:07 Denis4yk

@Denis4yk will do :) Please, tell me more about your setup, and how you use docker.

antonmedv avatar Jul 27 '18 05:07 antonmedv

@antonmedv I'm ready to help))

Here is my mail

[email protected]

Please, write your telegram phone number (or suggest any other option)

Denis4yk avatar Aug 04 '18 16:08 Denis4yk

https://github.com/deployphp/deployer/pull/1382

This is a good start.

fredericlebel avatar Aug 06 '18 21:08 fredericlebel

same problem “How to use Deployer with Docker containers?” look forward to v7 too.....

aen233 avatar Dec 29 '18 07:12 aen233

I sent the docker setup 1-2 months ago to the maintainer :)

Denis4yk avatar Dec 29 '18 08:12 Denis4yk

I sent the docker setup 1-2 months ago to the maintainer :)

Would you care to share a repo on this? There is a pull request by @blizzke already by the way.

jasperf avatar Jan 01 '19 06:01 jasperf

@jasperf

Of course :)

https://github.com/Denis4yk/laravel-docker-setup

-1. Clone
0. Install Docker
1. From the root run `docker-compose up -d` (tested only on mac)
2. Check in your browser `127.0.0.1`

Denis4yk avatar Jan 01 '19 13:01 Denis4yk

@Denis4yk Do not see here how deployer is used to deploy the app's code and work within the container to be able to execute PHP...?

jasperf avatar Jan 08 '19 23:01 jasperf

@jasperf Looks like you misunderstood me. It is just a setup of a Docker project :D

Cause not every dev knows how to set it up and the maintainer has to have a working docker setup in order to implement docker support.

So I decided to help with that :)

Denis4yk avatar Jan 09 '19 14:01 Denis4yk