Skip to content

Instantly share code, notes, and snippets.

@divdax
Forked from boris-glumpler/Envoy.blade.php
Created June 28, 2014 11:54

Revisions

  1. @boris-glumpler boris-glumpler revised this gist Jun 25, 2014. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Envoy.blade.php
    Original file line number Diff line number Diff line change
    @@ -29,12 +29,10 @@

    {{-- All directories symlinked to the shared folder --}}
    $symlinks = [
    'uploads' => 'public/uploads',
    'storage/views' => 'app/storage/views',
    'storage/sessions' => 'app/storage/sessions',
    'storage/logs' => 'app/storage/logs',
    'storage/cache' => 'app/storage/cache',
    'storage/backups' => 'app/storage/backups',
    ];

    {{-- DO NOT EDIT BELOW THIS LINE --}}
  2. @boris-glumpler boris-glumpler revised this gist Jun 25, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions Envoy.blade.php
    Original file line number Diff line number Diff line change
    @@ -18,10 +18,10 @@
    $keep = 6;

    {{-- Is the HTMLPurifier library installed --}}
    $hasHtmlPurifier = false;
    $hasHtmlPurifier = true;

    {{-- Files and direcrtories that need permissions of 755 and www-data as owner --}}
    $chmods = [
    $chmods = [
    'app/storage',
    'app/database/production.sqlite',
    'public',
    @@ -37,9 +37,9 @@
    'storage/backups' => 'app/storage/backups',
    ];

    {{-- DO NOT EDIT THESE VARIABLES --}}
    $date = new DateTime('now', new DateTimeZone($timezone));
    $release = $path .'/releases/'. $date->format('YmdHis');
    {{-- DO NOT EDIT BELOW THIS LINE --}}
    $date = new DateTime('now', new DateTimeZone($timezone));
    $release = $path .'/releases/'. $date->format('YmdHis');
    @endsetup

    {{-- Clone task, creates release directory, then shallow clones into it --}}
    @@ -120,4 +120,4 @@
    symlinks
    update-symlink
    done
    @endmacro
    @endmacro
  3. @boris-glumpler boris-glumpler revised this gist Jun 24, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions Envoy.blade.php
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@
    {{-- The timezone your servers run in --}}
    $timezone = 'Europe/Amsterdam';

    {{-- The base URL where your deployments are sitting --}}
    $baseUrl = '/var/www/site.com/htdocs';
    {{-- The base path where your deployments are sitting --}}
    $path = '/var/www/site.com/htdocs';

    {{-- The git repository location --}}
    $repo = '';
    @@ -39,7 +39,7 @@

    {{-- DO NOT EDIT THESE VARIABLES --}}
    $date = new DateTime('now', new DateTimeZone($timezone));
    $release = $baseUrl .'/releases/'. $date->format('YmdHis');
    $release = $path .'/releases/'. $date->format('YmdHis');
    @endsetup

    {{-- Clone task, creates release directory, then shallow clones into it --}}
    @@ -84,7 +84,7 @@
    {{-- Symlink some folders --}}
    @task('symlinks', ['on' => $on])
    @foreach($symlinks as $folder => $symlink)
    ln -s {{ $baseUrl }}/shared/{{ $folder }} {{ $release }}/{{ $symlink }}
    ln -s {{ $path }}/shared/{{ $folder }} {{ $release }}/{{ $symlink }}

    echo "Symlink has been set for {{ $symlink }}"
    @endforeach
    @@ -94,9 +94,9 @@

    {{-- Set the symlink for the current release --}}
    @task('update-symlink', ['on' => $on])
    rm -rf {{ $baseUrl }}/current
    rm -rf {{ $path }}/current

    ln -s {{ $release }} {{ $baseUrl }}/current
    ln -s {{ $release }} {{ $path }}/current

    echo "Release symlink has been set"
    @endtask
  4. @boris-glumpler boris-glumpler created this gist Jun 24, 2014.
    123 changes: 123 additions & 0 deletions Envoy.blade.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,123 @@
    {{-- Define all our servers --}}
    @servers(['staging' => '', 'production' => ''])

    @setup
    {{-- The timezone your servers run in --}}
    $timezone = 'Europe/Amsterdam';

    {{-- The base URL where your deployments are sitting --}}
    $baseUrl = '/var/www/site.com/htdocs';

    {{-- The git repository location --}}
    $repo = '';

    {{-- The git branch to deploy --}}
    $branch = 'master';

    {{-- The number of releases to keep --}}
    $keep = 6;

    {{-- Is the HTMLPurifier library installed --}}
    $hasHtmlPurifier = false;

    {{-- Files and direcrtories that need permissions of 755 and www-data as owner --}}
    $chmods = [
    'app/storage',
    'app/database/production.sqlite',
    'public',
    ];

    {{-- All directories symlinked to the shared folder --}}
    $symlinks = [
    'uploads' => 'public/uploads',
    'storage/views' => 'app/storage/views',
    'storage/sessions' => 'app/storage/sessions',
    'storage/logs' => 'app/storage/logs',
    'storage/cache' => 'app/storage/cache',
    'storage/backups' => 'app/storage/backups',
    ];

    {{-- DO NOT EDIT THESE VARIABLES --}}
    $date = new DateTime('now', new DateTimeZone($timezone));
    $release = $baseUrl .'/releases/'. $date->format('YmdHis');
    @endsetup

    {{-- Clone task, creates release directory, then shallow clones into it --}}
    @task('clone', ['on' => $on])
    mkdir -p {{ $release }}

    git clone --depth 1 -b {{ $branch }} "{{ $repo }}" {{ $release }}

    echo "Repository has been cloned"
    @endtask

    {{-- Updates composer, then runs a fresh installation --}}
    @task('composer', ['on' => $on])
    composer self-update

    cd {{ $release }}

    composer install --no-interaction --no-dev --prefer-dist

    echo "Composer dependencies have been installed"
    @endtask

    {{-- Set permissions for various files and directories --}}
    @task('chmod', ['on' => $on])
    @foreach($chmods as $file)
    chmod -R 755 {{ $release }}/{{ $file }}

    chmod -R g+s {{ $release }}/{{ $file }}

    chown -R www-data:www-data {{ $release }}/{{ $file }}

    echo "Permissions have been set for {{ $file }}"
    @endforeach

    @if($hasHtmlPurifier)
    chmod -R 777 {{ $release }}/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer
    @endif

    echo "Permissions for HTMLPurifier have been set"
    @endtask

    {{-- Symlink some folders --}}
    @task('symlinks', ['on' => $on])
    @foreach($symlinks as $folder => $symlink)
    ln -s {{ $baseUrl }}/shared/{{ $folder }} {{ $release }}/{{ $symlink }}

    echo "Symlink has been set for {{ $symlink }}"
    @endforeach

    echo "All symlinks have been set"
    @endtask

    {{-- Set the symlink for the current release --}}
    @task('update-symlink', ['on' => $on])
    rm -rf {{ $baseUrl }}/current

    ln -s {{ $release }} {{ $baseUrl }}/current

    echo "Release symlink has been set"
    @endtask

    {{-- Migrate all databases --}}
    @task('migrate', ['on' => $on])
    php {{ $release }}/artisan migrate
    @endtask

    {{-- Just a done message :) --}}
    @task('done', ['on' => $on])
    echo "Deployment finished successfully!"
    @endtask

    {{-- Run all deployment tasks --}}
    @macro('deploy')
    clone
    composer
    chmod
    migrate
    symlinks
    update-symlink
    done
    @endmacro