Coder Social home page Coder Social logo

erdmenchen / laravel-bitbucket-deploy Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 152 KB

Deploy your laravel app via bitbucket pipelines and envoyer.

License: GNU General Public License v3.0

PHP 34.40% Blade 65.60%
laravel-package php bitbucket-pipelines laravel deployment

laravel-bitbucket-deploy's Introduction

laravel-bitbucket-deploy

Deploy your laravel app via bitbucket pipelines and envoyer.

Important:
Be sure, that your project (migrations!) is working as expected (tests!), because there is no backup mechanism during the deployment!
Do not deploy to production only, always test releases on staging before!

Prerequisites

  • Bitbucket account
  • Bitbucket Pipeline build minutes available (the free plan has 50min per month)
  • Hosting with SSH access

Installation

You can easily install this package using Composer by running the following command:

composer require erdmenchen/laravel-bitbucket-deploy

After installation completed run the following command in order to install all required assets:

php artisan vendor:publish

Bitbucket Configuration

In order to get the build and deployment pipeline going at Bitbucket, you need to make the following steps in your Bitbucket repository:

  1. Enable Pipelines
  2. Add the repository variables: DEPLOY_HOST and DEPLOY_USER
  3. Create a new SSH key, add your host to the known hosts and copy the public key to your hosting
  4. Create the following deployment environments and set the variable DEPLOY_PATH for each:
    • Staging
    • Production

Hosting Configuration

The deployment script requires the following folder structure on the web hosting in order to work:

  • Deployment Target Folder (e.g. cool_website_staging)
    • .env (Laravel environment config file)
    • releases (each deployment will be placed here by the script in unique folders)
    • storage (Laravel storage folder)
      • framework/sessions
      • framework/views
      • framework/cache

During each deployment, the .env file and the storage folder are referenced into the current build folder via symlinks. Additionally a symlink current will be created (or updated) in the deployment folder, which points to the latest build folder.

To always point the webserver to the latest release, just create a symlink, that points on the current symlink (e.g. cool_website.com -> cool_website_staging/current/public. You don´t need to edit it during deployment. It will always point to the latest release.

Requirements

This package has the following requirements:

  • PHP 7.3 or higher
  • Laravel 6.0 or higher

How it works

This package scaffolds a Bitbucket pipeline script and a Laravel Envoyer script into your Laravel project.

When a new pipeline run is triggered (via git commit or manually) a full CI/CD (Continuous Integration/Continuous Delivery) build is executed with the following steps:

  1. Fetch source code and install PHP dependencies (Build PHP)
  2. Run phpunit and gather results - stops on any failed test (Test PHP)
  3. Install javascript dependencies via npm and build UI assets(Build Assets)
  4. Deploy to staging / production - connects to hosting via ssh and pushes build (Deploy)
    • Create manifest file with original trigger commit details
    • Create symlinks to .env and storage
    • Check Laravel health (running php artisan --version)
    • Activate build by updating the current symlink
    • Optimise, migrate and cleanup Laravel project

The last step (step 4) is only executed when triggered from a commit on develop or master branch. Feature branches are build only, they do not get deployed.

License

The GNU General Public License v3.0. Please see License File for more information.

laravel-bitbucket-deploy's People

Contributors

dependabot[bot] avatar erdmenchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-bitbucket-deploy's Issues

Veryfing installation task did not complete successfully.

Hi @erdmenchen ,
Hope you are well!

I am experiencing some issues with one of the deployment steps. The build is breaking on the 'verify_install' task. Here is a screenshot:

image

It is breaking on this line:

{{ $php }} artisan --version

Do you have any ideas about what's going on and how I can proceed/debug this issue?

Kind Regards,
Ivaylo Tsvetanov

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.