Overview
This project uses simple bash scripts to deploy and rebuild a Quartz site within a Docker container.
By default, if no volumes provided, container will clone default Quartz repo and use docs as content.
The Scripts
-
bootstrap.sh
This is the main script that runs at the startup of the container. It performs the following tasks:- Checks if the Quartz repository is already cloned.
- If the repository is not present, it clones the specified Quartz repository (private or public) into the container.
- If the repository is already cloned, it skips the cloning step and prepares the environment for Quartz to run.
- Optionally checks out a custom branch if defined in the environment variables.
- Perfroms initial Quartz build by running
build-quartz.sh - Optionally runs
watch-and-build-quartz.shscript. Defaults to true. - Starts webhook service, if enabled.
-
build-quartz.sh
A simple script that runsnpx quartz build.- It looks for the Obsidian vault at
$VAULT_DIR, which defaults to/vault. - It stops with an error if that directory does not exist. An existing but empty one is fine, it builds an empty site and says so in the log.
- It outputs build files into
/usr/share/nginx/html
- It looks for the Obsidian vault at
-
watch-and-build-quartz.sh
This script triggers a rebuild of the Quartz site:- Watches the vault for changes, including subfolders, and folders added later.
- When notes are updated, the script waits for a set delay to ensure no more edits are happening, then runs the
build-quartz.sh.
-
server.jsSimple node express app that serves as webhook to start Quartz build on demand. More here
Paths in the Container
-
Obsidian Vault:
Each timebuild-quartz.shruns, it instructs Quartz to look in$VAULT_DIRfor content, which defaults to/vault.
When mounting, make sure to use the root directory of your Obsidian vault and mount it to/vault.
SetVAULT_DIRif the notes live somewhere else in the container, for example in thecontentfolder of your own Quartz repo. See Importing Obsidian Vault. -
Quartz Directory:
The Quartz repository is cloned into/usr/src/app/quartz.
This is where all the Quartz files will be stored inside the container.
For more details on how to provide your own Quartz repository, see Providing Quartz. -
Scripts Directory:
Thebootstrap.sh,build-quartz.shandbuild-and-watch-quartz.shscripts are located in/usr/src/app/scripts. -
NGINX Configuration:
During the image build,nginx.confis copied to/etc/nginx/nginx.conf.
To persist and customize the NGINX configuration, you can use bind mounts. -
Logs Directory:
NGINX logs are stored in/var/log/nginx, which can be helpful for monitoring access and error logs.
Environment Variables
-
GIT_REPO:
The URL of your Quartz repository. -
GIT_BRANCH:
The branch to check out (optional). -
BUILD_UPDATE_DELAY:
The delay (in seconds) the script will wait after detecting file changes before triggering a Quartz rebuild. -
AUTO_REBUILD:
Set this to enable automatic rebuilding when file changes are detected. Usetrueto enable orfalseto disable. -
REBUILD_WEBHOOK_SECRET: Set to something strong, for example:UQjO8DJKf9CfA9Gd8cDJmhsjPnKl8MLZIf set, you can send a post request tohttp://<ip>:<port>/rebuild/UQjO8DJKf9CfA9Gd8cDJmhsjPnKl8MLZto trigger Quartz Build -
NOTIFY_TARGETApprise target to send notifications to (Slack, Discord, Telegram, Ntfy, etc.). Triggers on build start, success or fail. -
VAULT_DO_GIT_PULL_ON_UPDATEExecute git pull in the vault directory before rebuild Usefull when storing vault in git repository Do initial pull before setting this and make sure container can access the repo default false -
VAULT_DIRWhere the notes are inside the container. Defaults to/vault, which is the mount point everything else in the docs uses. Point it at/usr/src/app/quartz/contentto build the notes that came with your own Quartz repo. If the directory does not exist the container stops with an error.