rpsimao/laravel-deploy-helper

Helper for Laravel to deploy from artisan

2.0.3 2019-10-02 09:53 UTC

README

Dependency Status StyleCI Packagist Packagist license Made by DALTCORE FOSSA Status

Compatible with Laravel 5.1, 5.4 and higher.

For Laravel 5.1 use branch 5.1 and tag v0.5.x

LDH is a Laravel package that helps with deploying your website without the usage of FTP.
The LDH packages uses SSH to build a deployment environment on the server for zero-downtime deployments
and rollback functionality.

Everyone is allowed to help getting this package bigger and better! ;-)

Install

Via Composer

$ composer require daltcore/laravel-deploy-helper

In your config/app.php

DALTCORE\LaravelDeployHelper\LdhServiceProvider::class,

Publish configuration

$ php artisan vendor:publish --tag=ldh-config

Usage

Deploy to server
Deploy full instance to the remote server

php artisan ldh:deploy --stage=production --branch=develop

Patch to server
Push a simple patch to the remote server (minor changes only)

php artisan ldh:patch --stage=production --branch=patch

Rollback one instance
Something went horrably wrong, go back in history

php artisan ldh:rollback --stage=production

Configuration

stages
In the stages section you have to define your stages information.

git
You can use git's http url with basic auth. Example: https://username:password@github.com/repo/name.git .
You can use git's ssh. Example: git@github.com:repo/name.git

connection
In the connection section you can add your ssh details for deploying

remote.root
Here you can put the root directory where LDH can set up it's directory structure

commands
This is a array with commands that needs to be executed from the /current directory

shared.directories
This is te section with directories that needs to be copied from the previous deploy to the next one

shared.files
The same as with the directories, but then with files.

config.dependencies
Here you can optionally put some dependencies (applications) that you want to use for deploy.
You can use this for checking if everything on the server is setup correctly with the versions.
You may want use 'true' for no version checking, but instead just checking if the application exists.

config.keep
How many 'shadow' copies of the old deploys needs to exist. These come in handy for the rollback feature.

Config example:

<?php

return [
    'default' => [
        'stage' => 'production',
    ],

    'stages' => [
        'production' => [
            'git' => '',

            'branch' => '',

            'connection' => [
                'host'     => '',
                'username' => '',
                'password' => '',
                // 'key'       => '',
                // 'keytext'   => '',
                // 'keyphrase' => '',
                // 'agent'     => '',
                'timeout'  => 10,
            ],

            'remote' => [
                'root' => '/var/www',
            ],

            'commands' => [
                'composer install',
            ],

            'shared' => [
                'directories' => [
                    'public',
                    'storage',
                ],
                'files'       => [
                    '.env',
                ],
            ],

            'config' => [
                'dependencies' => [
                    'php' => '>=5.6',
                    'git' => true,
                ],
                'keep'         => 4,
            ],
        ],
    ],
];

Directory structure

LDH deploys the following directory structure on first deploy

.
├── current -> /var/www/vhosts/example.org/releases/1498833243
├── ldh.json
├── patches
│   └── 0001-Update-readme.md.patch
├── releases
│   └── 1498833243
└── shared

As you can see, LDH makes a static link from /current to /releases/1496845077.
You you only have to point your vhost to the /current/public for your Laravel website to work.

License

FOSSA Status