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.
How this works:
- when you start your project, add the git remote for gandi, as specified in your Gandi Simple Hosting dashboard
- develop and run your project locally (using e.g. php artisan serve)
- when you want to deploy, you commit the changes to the master branch
git commit -a
- you then push the changes to the Gandi git server
git push gandi master
- 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
- this will retrieve the correct git server, web server, user name for this website and store them locally in a dotfile.
- 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
- 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 stageor
./gdeploy.sh push prodto choose where I’m pushing the code,
./gdeploy.sh allto commit, push and deploy new code to Gandi, in 1 go