Easy site deployment on Gandi with git and gdeploy

I’m doing more and more Laravel development and I’m hosting these projects on Gandi.net Simple Hosting. I’ve switched completely to Gandi’s deploy with git method.

Gandi’s “Deploy with git”

How this works:

  1. when you start your project, add the git remote for gandi, as specified in your Gandi Simple Hosting dashboard
  2. develop and run your project locally (using e.g. php artisan serve)
  3. when you want to deploy, you commit the changes to the master branch
    • git commit -a
  4. you then push the changes to the Gandi git server
    • git push gandi master
  5. you then start deployment from the Gandi git server to the web server. This will also do a composer install (if there is a composer.lock file) and a npm install (if there is a package-lock.json file)
    • ssh <id>@<gitserver> deploy <website>.git

I have multiple Gandi Simple Hosting servers and I found it confusing to keep track of what server I was supposed to deploy to for each site. So I developed gandi_deploy. This is how that works:


  • what should already be installed: git, cli.gandi.net
  • clone this repository somewhere on your machine
    git clone https://github.com/pforret/gandi_deploy.git
  • from any of your Gandi git-managed project, add a symbolic link to gdeploy.sh
    ln -s /path/to/gandi_deploy/gdeploy.sh .
  • initialise the script for your project, type the domain name of your site if it cannot be guessed from the folder name
    ./gdeploy.sh init
  • this will retrieve the correct git server, web server, user name for this website and store them locally in a dotfile.

Easy deployment

  • my most common usage is: ./gdeploy.sh all: this does all 3 steps: commit-push-deploy one after the other, It might take more than 30 secs, but I just have to wait for it to finish.
  • I can also choose to run them one by one as ./gdeploy.sh commit, then ./gdeploy.sh push, and finally ./gdeploy.sh deploy.
  • for non-Laravel sites, when there is no php artisan serve, I can start a local webserver with ./gdeploy.sh serve (on port 8000) or ./gdeploy.sh rnd (on a random port between 8000 and 8099)
  • to login to the remote SSH serve, I can use ./gdeploy,sh ssh. This uses gandi paas remote to start the SSH access.
  • for sites where I have a staging server and a production server, I can redefine different remotes (git remote add stage ...) and then use ./gdeploy.sh push stage or ./gdeploy.sh push prod to choose where I’m pushing the code,

./gdeploy.sh all

to commit, push and deploy new code to Gandi, in 1 go

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.