Categories: Software Development

Single command deploying Laravel 5.x to Ubuntu VPS with Envoy

In case you are not familiar with Laravel Envoy, this is a short description from Laravel doc:

Laravel Envoy provides a clean, minimal syntax for defining common tasks you run on your remote servers. Using Blade style syntax, you can easily setup tasks for deployment, Artisan commands, and more. Currently, Envoy only supports the Mac and Linux operating systems.

After several Laravel 5.x projects, I decided an Envoy deployment script that works for most of my needs. It is based on Gitlab CI Laravel example that uses rolling deployment pattern (using symbolic links) to minimize downtime. Assuming some of you may have similar needs, I decided to publish it in my Github Gist and write some explanation in this post.

My script requires some prerequisites below. If you can not fulfill one or more of these, you may need to change some parts. Prerequisites:

  1. Laravel prerequisites are installed on target server
  2. Two private (for source code and data) and one public (for index.php and public assets) directories are available on server
  3. Server is accessible with sudoer that requires NO password. This is required to run commands that requires sudo (eg. chown to www-data, ln in /var/www, rm www-data files)
  4. Server runs web server (Apache/Nginx) using www-data user. Otherwise you need to change every www-data occurrence in the script
  5. Server’s public key has been registred as Deploy Keys in GitLab (required unless you are using public repo)
  6. Server has registered GitLab as known server. You can do it by running git clone manually from the target server

Additionally, you can uncomment some optional parts to have these features:

  1. Supervisord queue worker: setup, update, refresh worker cache. It assumes you commit a worker configuration like this. It will be copied to Supervisord default directory during deployment
  2. Laravel Passport: setup (generate secret keys)
  3. Migrate database: migrate or fresh (drop/create all)
  4. Temporary directory (eg. to store generated files)

In case you missed, these are the links to the source:

0 0 votes
Article Rating
yohanes.gultom@gmail.com

View Comments

Share
Published by
yohanes.gultom@gmail.com

Recent Posts

Get Unverified SSL Certificate Expiry Date with Python

Getting verified SSL information with Python (3.x) is very easy. Code examples for it are…

3 years ago

Spring Data Couchbase 4 Multibuckets in Spring Boot 2

By default, Spring Data Couchbase implements single-bucket configuration. In this default implementation, all POJO (Plain…

3 years ago

Firebase Auth Emulator with Python

Last year, Google released Firebase Auth Emulator as a new component in Firebase Emulator. In…

3 years ago

Google OIDC token generation/validation

One of the authentication protocol that is supported by most of Google Cloud services is…

4 years ago

Fast geolocation query with PostGIS

If you need to to add a spatial information querying in your application, PostGIS is…

4 years ago

Auto speech-to-text (Indonesian) with AWS Transcribe and Python

Amazon Web Service Transcribe provides API to automatically convert an audio speech file (mp3/wav) into…

4 years ago