Automatic Deployment of a Laravel Application with Buddy.works

profile picture

Automatic Deployment of a Laravel Application with Buddy.works

I guess we all know Laravel Forge and Laravel Envoyer, which is probably the best combination of hosting and deploying Laravel applications.

However, maybe you don't use Laravel Forge because you have your own dedicated server on which you host several Laravel apps. And also, you need to only deploy your Laravel app when all tests are green, and that should be done automatically on any commit.

Laravel Envoyer doesn't run your tests, unfortunately, so you can't fully automate a deployment on any commit.

This is where https://app.buddy.works comes into action ! And best thing is, it has a free plan (as long as you don't setup more than 5 projects).

I assume the following:

  • Your project as at least one Test.
  • You use a database
  • The project is already setup and linked to a git repository on your server
  • You can ssh into your server with an ssh key.

Ok ! If that's what your looking here's the detail of my deployment plan :

PHPUnit Step Setup

In the "Run Commands" section, copy paste theses lines : 

# Prepare .env file
cp .env.example .env
sed -i "s/127.0.0.1/mysql/g" .env
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=root/g" .env
sed -i "s/DB_PASSWORD=secret/DB_PASSWORD=qwerty/g" .env
# Install Composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# Setup Database
echo "create database homestead" | mysql --host=mysql --user=root --password=qwerty
# Run Laravel commands
composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
./vendor/bin/phpunit

I assume your .env.example file in your project look like this

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

In the Configuration > Environment section, you need to use this docker image

The Package Setup section :

And in the "Services" section, you simply need to add a Mysql Service and that's it :)

The SSH - Deployment Step

The End !

The Slack step is actually so easy that you don't need screenshots :)

Enjoy !

deployment
ci
cd
automatic
continuous
integration
buddy.works

about me

profile picture

I consider myself as an IT Business Artisan. Or Consultant CTO. I'm a self-taught Web Developper, coach and teacher. My main work is helping and guiding digital startups.

more about me

follow me

newsletter

A weekly email with the latests articles

support my work

Start trading on binance
  • BTC

    BTC

    18SY81ejLGFuJ9KMWQu5zPrDGuR5rDiauM

  • ETH

    ETH

    0x519e0eaa9bc83018bb306880548b79fc0794cd08

  • Monero

    XMR

    895bSneY4eoZjsr2hN2CAALkUrMExHEV5Pbg8TJb6ejnMLN7js1gLAXQySqbSbfzjWHQpQhQpvFtojbkdZQZmM9qCFz7BXU

recent posts

QBUS - MQTT Quick Tutorial

1
10 months ago

DDOS By Web Crawlers

1
1 year ago

Something Given

1
1 year ago

2024 © My Dynamic Production SRL All rights Reserved.