2017 © Pedro Peláez
 

library laravel-remote-deploy

Deploy Laravel sites to a remote server directly from Artisan

image

jsefton/laravel-remote-deploy

Deploy Laravel sites to a remote server directly from Artisan

  • Friday, March 16, 2018
  • by jsefton
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Remote Deploy

This package allows you to define a remote server and directory that you can then push your changes to with a simple command directly from your local., (*1)

It allows you to create groups of commands into tasks so they can easily be ran on a remote server. This can be used for deployment, provisioning, health checks and much more., (*2)

Installation

You will need composer to install this package (get composer). Then run:, (*3)

composer require jsefton/laravel-remote-deploy

Register Service Provider

Add the below into your config/app.php within providers array, (*4)

Jsefton\LaravelRemoteDeploy\LaravelRemoteDeployProvider::class

After installation you will need to publish the config file which will allow you to specify your own list of environments. To do this run:, (*5)

php artisan vendor:publish --tag=laravel-remote-deploy

This will create the file config/laravel-remote-deploy.php where you can configure your list of environments., (*6)

Configuration

Inside config/laravel-remote-deploy.php you will have 2 sets of configurations., (*7)

This includes servers, which is an array of all the possible connections you will want to create and connect too., (*8)

This also includes a set of tasks that you can then select from to run. It can contain multiple commands and feature file uploads. Below is an example config for setup and deploy:, (*9)

'setup' => [
    'directory' => '/',
    'commands' => [
        "ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' " => [
            'confirm' => 'Do you want to create an ssh key'
        ],
        'cat ~/.ssh/id_rsa.pub',
        'cd /var/www/html',
        'git clone' => [
            'confirm' => 'Have you installed your ssh key with the repository yet?',
            'prompt' => 'Please enter a url for the git repository'
        ]
    ]
],
'deploy' => [
    'directory' => '/var/www/html',
    'commands' => [
        'cd' => [
            'prompt' => 'Please enter a folder name of the site'
        ],
        'git pull origin master'
    ]
]

Usage

When in the CLI run the below to execute the command and begin the prompts, (*10)

php artisan remote:tasks

To clear out any stored credentials in temporary files run:, (*11)

php artisan remote:clear

TODO

  • Include Migrate Environments package to allow easy database updating with deploy
  • Add ability to run same task on multiple servers

Provision task

THIS IS CURRENTLY IN DEVELOPMENT, (*12)

By adding the below in your tasks config it will allow you to provision a basic LEMP stack, (*13)

'reboot' => [
    'directory' => '/',
    'commands' => [
        'reboot'
    ]
],
'provision' => [
    'directory' => '/',
    'commands' => [
        'sudo apt-get update',
        'sudo apt-get install nginx -y',
        'sudo apt-get install mysql-server -y',
        'sudo apt-get install php-fpm php-mysql -y'
    ],
    'files' => [
        [
            'path' => '/etc/nginx/sites-available/default',
            'content' => 'server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;

server_name server_domain_or_IP;

location / {
    try_files $uri $uri/ =404;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

location ~ /\.ht {
    deny all;
}
}',
            'after' => [
                'sudo nginx -t',
                'sudo systemctl reload nginx'
            ]
        ]
    ]
]

The Versions

16/03 2018

dev-master

9999999-dev https://github.com/jsefton/laravel-remote-deploy

Deploy Laravel sites to a remote server directly from Artisan

  Sources   Download

MIT

The Requires

 

by Jamie Sefton

laravel artisan deployment deploy build production go live