We want to use a pipeline to run phpunit for our Laravel project every time something is committed. I've tried to set this up, but had no luck. I guess it doesn't really help that I am not that familiar with Docker.
Some questions:
Is it necessary to run `composer install` every time? We have a moderately large project and I noticed this can take up to 7 minutes. I vaguely know what Docker images are, but can't quite figure out if they would be of any help here.
Is there perhaps anyone who has managed to successfully set up a Bitbucket pipeline for a Laravel project?
Thanks in advance,
Michael
Hi Michael,
A docker image is effectively a snapshot of a system at a specific point. Once you run it it works a little like a virtual machine and can be modified and edited as you wish. Because of this using a specific docker image could cut down on the time to install composer or php but it will not also have your dependencies downloaded. You will have to continue to run 'composer install'. I would definitely recommend checking out the docker docs located here: https://docs.docker.com/engine/understanding-docker/
As for the problem of not being able to run artisan after the command finishes I have a few suggestions. If you're not installing artisan globally that might explain not being able to run the command. The first step is to get the docke rimage running locally and then executing the commands on the docker image and seeing whether the problem persists and whether there is a way to diagnose the problem. If this does not work you can raise a support ticket at https://support.atlassian.com/
Cheers,
Tom
Thanks for your answer Tom. I guess delving into Docker a bit more is unavoidable. Will do when I get the time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Michael, we have successfully set up a working laravel development pipeline, where artisan works without problems. A few suggestions:
make sure your docker image has a working php version installed. We are using `image: phpunit/phpunit:5.0.3`as the docker image, it comes with everything preconfigured to run laravel deployments. Since composer already works, it could be the wrong php version or something else related to your php version.
If you want, I can paste a working laravel deployment queue for a target linux machine for you somewhere. Just let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, `php artisan` instead of just `artisan` made the difference. There are still some issues to be resolved though. Like for instance disabling xdebug for composer. I suppose this has to be done from the command line somehow. Furthermore, although both the command `composer install` and `php artisan` finish successfully now, we get the following error when expanding the log for each of these two steps:
{"error":{"type":"ErrorException","message":"file_put_contents(\/meta\/services.json): failed to open stream: No such file or directory","file":"\/opt\/atlassian\/bitbucketci\/agent\/build\/vendor\/laravel\/framework\/src\/Illuminate\/Filesystem\/Filesystem.php","line":70}}
It would be great if you could share your laravel setup. I would appreciate this very much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've just been experimenting with getting this in place with a fresh Laravel 5.3 install, my pipelines file is this which seems to work:
# This is a sample build configuration for PHP. # Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: phpunit/phpunit:5.0.3 pipelines: default: - step: script: # Modify the commands below to build your repository. - php -r "file_exists('.env') || copy('.env.example', '.env');" - composer install - php artisan key:generate - phpunit
Next step is database testing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Paul van Hemmen and @James Fairhurst I'm trying to do the same thing as you guys, but can't find a lot of documentation to help a newb out. I have a Laravel 5.1 app in Bitbucket and would love to use Pipelines to push it out to my Beanstalk instance. Can you guys provide a bit more detail or resources to try and get this working? Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Michael Dzjaparidze
i used this one
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.