@flaki/daemon v1.0.0-alpha
Dǣmon
For a moment I wanted to call this "Me-tlify", but I would rather not unleash the wrath of trademark rights lawyers, however it does illustrate pretty well what this tool is for.
Dǣmon lets you create self-hosted (for now, static) site deployments that react and respond to code repository changes. You can have multiple static sites deployed under various "environments", which react automatically to repo changes (e.g. pushes).
Currently only GitHub webhooks supported, but anything else should be fairly easy to implement (Gitlab is on the roadmap). Well, there's no actuall roadmap, but I'm thinking about it anyway.
Installation & use
npx @flaki/daemon <configfile.conf>
Debugging
DEBUG=1, DEBUG=verbose
Logging incoming webhooks.
Configuration
The configuration file follows the .env file format, uppercase alphanumeric keys followed by = and the value, one value one row.
The following keys may be used in the configfile:
| Key | Value |
|---|---|
PORT | Port to listen for incoming webhooks, default: 9999 |
HMAC_KEY | The HMAC-SHA-256 digest secret used for signing incoming webhook payloads |
WORKDIR | The direrctory where the git repo resides, Dǣmon will pull & run commands in this repo |
REPO | The repository name to operate on, needed so that Dǣmon does not get confused by noise from other webhooks referencing events in other repositories |
ENVS | The branches Dǣmon should handle, comma separated list of branchname:port values, where port is the port number where the generated site for this branch will be served from |
OUTDIR | Defaults to _deploy. Dǣmon passes this and the branch in the environment variable OUTPUT_DIR to BUILDCMD, e.g.: OUTPUT_DIR=_deploy/mybranch npm run build |
BUILDCMD | The command to execute after a successful pull, defaults to npm run build |
LOGSDIR | Enable logging incoming webhook payloads in the given folder, ideal for debugging and feature development (default: no logging) |
Q & A
Is this Serverless™?!
Au contraire, this is Server-YES! Dǣmon runs as a Node.js application, listens to incoming webhooks, and serves the generated websites (branches) on different ports as a static server, so it requires to be run, somewhat unsurprisingly, as a daemon.
Only works with static sites?
Yes, albeit this might change in the future. In all practicality you can bend Dǣmon to your will through configuration even today, but the currently intended primary use case is static sites.
npm keeps screaming about critical vulnerabilities
Dǣmon has (intentionally) few dependencies, node-static is currently the only one. I am currently waiting for a maintainer change to realize, at which point these issues shall be fixed. If that doesn't happen in due time I'll look into replacing the dependency with a fork or in its entirety.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago