Automatically deploy Sphido website from GitHub to Caddy server

Caddy server is the HTTP/2 web server with automatic (free) HTTPS with Let's Encrypt. It is lightweight, fast, easy to configure, easy to maintain and modern.

Caddy also supports optional git plugin makes it possible to deploy your site with a simple git push.

Configure Caddy server

Let's have Caddyfile with follow content: {
} {    

  root /var/www/
  log  /var/www/
  errors /var/www/

  git {
    path /var/www/
    hook /update *** your secret goes here ***
    hook_type generic
    then make

  header / Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

The git directive starts a service routine that runs during the lifetime of the server. When the service starts, it clones the repository. While the server is still up, it pulls the latest every so often. You can also set up a webhook to pull immediately after a push. In regular git fashion, a pull only includes changes, so it is very efficient.


  yarn install --dev --no-color
  rm -rf ./public
  mkdir -p log public
  yarn run build

PHONY: update


cache-folder ".cache"
yarn-offline-mirror ".npm"
yarn-offline-mirror-pruning true
--install.prefer-offline true true

Webhook on GitHub