Upgrade Forge-Pushed Site To Envoyer

Upgrading is easy, cleaning up is a bit tricky.

Reasoning 

Often you will want to "upgrade" your deployment strategy as your project grows from initial development and moves into going live, in order to take care of zero-downtime-deployment goodness that is Envoyer.

Specifically:

  • we want to avoid as much down-time as possible (there shouldn't be any if all goes as planed).
  • we want to clean up all the left-overs after upgrading to Envoyer to keep our server environment clean. (This goes to minimizing possible confusion during later maintenance.)

Preparation 

Follow Taylor's setup instructions on LaraCasts. By the end you should have configured your project in Envoyer.

This complete process is customized to your domain name:   

Procedure 

It’s actually very straight-forward to get your existing forge-git-hooked site to deploy out:

  1. Remove any pre-existing Forge deploy hooks that were set up on your git provider.
  2. Follow Taylor’s setup instructions on Laracasts. This should include setting up your deploy-on-commit hook, as well as the SSH key on Forge.
  3. Copy your environment configuration:
    1. Log into Laravel Forge.
    2. Select your web site from the Sites drop-down.
    3. Select Edit Files, then click the Edit Environment File button.
    4. Copy the settings.
  4. Now lets transfer that to your Envoyer project:
    1. Log info Laravel Envoyer.
    2. Select the project you are working on.
    3. Select the Server tab, then click the Manage Environment button.
    4. If this is the first time you are managing the environment settings you will be prompted to create a password. If you already set this up, you will be prompted for your password.
    5. Paste your environment variables you copied from Forge, and click the Update On Servers button.
  5. Push your Envoyer project out when you’re ready.
  6. Update the site root directive in Forge:
    1. Select Edit Files and click Edit Nginx Configuration.
    2. Change the site_root directive to:
      root /home/forge/{{ domain ? domain : domainPlaceholder }}/current/public;
  7. SSH into your server and clean up the Forge remnants:
    Please make sure that all non-versioned (so those not in Git, SVN, etc.) files are backed up. This set of commands will remove all other folders.


    ssh -t forge@{{ domain ? domain : domainPlaceholder }} "cd {{ domain ? domain : domainPlaceholder }}; bash"
    find . -maxdepth 1 -not -name “.” -not -name “current” -not -name “storage” -not -name “releases” -not -name “.env” -exec rm -rf {} \;