Deployment
Documentation of web resources deployment configuration, including instructions for the maintenance and creation of applications.
Index
The droplet is set up to serve applications using nginx as a reverse proxy; a service that can take requests to the droplet itself and redirect them to specific services. This enables different website addresses pointing to the droplet to serve as internal addresses for locations or services on the machine. Changing nginx configuration or adding sites to /var/www require super user privileges or altered file access permissions.
Continuous Integration using a Git Hook1
Site content is owned by a dummy git user on the droplet, created to facilitate access to deployment repositories which live in their home directory. (/home/git/<sitename>.git). By convention, a symbolic link provides static site content to /var/www/<site-address.ca> from which it is served by nginx. In this way, anyone can contribute to web services from a common dummy user without requiring super user privileges.
Git repositories provide a number of event triggered scripts called “hooks”. The post-receive hook is trigged after any push to the repository, which lets us dynamically populate content or restart an updated service whenever it is changed.
Local Setup
See Wiki - Contributing for access information.
On your local development machine, you’ll need to set up a repo to push from, using the droplet as a remote.
- create up a distribution folder
- this could be your front end build folder, or just somewhere that you copy desired files into with a script when deploying
- initialize a local repository with
git init - configure live remote pointing to the location of your bare repository
git remote add live ssh://droplet-git/~/my-site.git
or ~/my-service.git
- add, commit, and
git push live main- you should be prompted for your ssh key and then see your files pushed through
- optional - add script to automate the deployment process
- note: the script process needs to be user aware to use your ssh key
- example cmd script following npm build:
cd dist
git add .
git commit -m "Updates from script deployment"
git push live main