How to deploy a project in laradock ?
| 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!
I never worked with laradock, can't tell.
@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.
You need to connect to laradock by ssh.
@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:
- I keep getting this warning
To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcDeven though I'm pretty sure I've installed thezipextension in the appropriate containers. - 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.
The unzip extension you can add to your PHP worker. As for the other errrors, I would check logs in workspace.
@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 laradock created only for local development?
@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?"
How to use Deployer with Docker containers?
Good question. :) Now not. Will be in v7.
@antonmedv Thanks for your response! I look forward to v7.
+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 will do :) Please, tell me more about your setup, and how you use docker.
@antonmedv I'm ready to help))
Here is my mail
Please, write your telegram phone number (or suggest any other option)
https://github.com/deployphp/deployer/pull/1382
This is a good start.
same problem “How to use Deployer with Docker containers?” look forward to v7 too.....
I sent the docker setup 1-2 months ago to the maintainer :)
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
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 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 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 :)