Deploy static website with rsync
2020-06-21
Create a Makefile and use rsync
to deploy your ./public
folder to a remote server. Replace <IP-ADDRESS>
with the website location and set FOLDER
to the remote location where you want to upload your local files. In practice it’s nice to have a staging folder to test out your website before deployment. Use make staging
and make deploy
to sync changes.
.PHONY: staging deploy
SERVER = <IP-ADDRESS>
FOLDER = /var/www/html
STAGING = /var/www/html/staging
USER = root
deploy:
rsync -zarvh ./public/* --compress --recursive --checksum --delete --itemize-changes --exclude-from exclude.rsync $(USER)@$(SERVER):$(FOLDER)
staging:
rsync -zarvh ./public/* --compress --recursive --checksum --delete --itemize-changes --exclude-from exclude.rsync $(USER)@$(SERVER):$(STAGING)