Compare commits

..

No commits in common. "5c2597498dd272fc0ba78234687141d15749dcb3" and "f83d404abe35ff7cb46ca77701ecafc07b34bffa" have entirely different histories.

2 changed files with 46 additions and 32 deletions

View file

@ -10,32 +10,46 @@ date: 2025-01-16
docker pull code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
```
This project runs **Quartz 4.4.0**, a fast, batteries-included static site generator, inside a **Docker container**. It transforms Markdown content into a fully functional website.
This project runs **Quartz 4**, a fast, batteries-included static site generator, inside a **Docker container**. It transforms Markdown content into a fully functional website.
While Quartz provides [Docker support](https://quartz.jzhao.xyz/features/Docker-Support), it is not as self contained as this project.
I explored several alternative approaches for configuration within this container, but none met my criteria for simplicity—specifically, avoiding the need to mount the entire site source and instead only requiring a dedicated `content` and `config` directory.
## 🚀 Features
- **Easy Configuration** Customize settings using a json file
- **Automated Site Updates** Configurable cron job to fetch and rebuild content
## 🐳 Docker Compose Setup
Create a data directory
### Prepare Data Directories
Create a data directory and pull your existing content
```bash
mkdir -p /srv/quartz
# create directories
mkdir -p /srv/quartz/config
cd /srv/quartz
# clone your content
git clone https://code.modernleft.org/gravityfargo/modernleft-docs.git content
```
### Compose File
Create a `docker-compose.yml` file:
![[docker-compose]]
**First Run**
### First Run
```bash
docker-compose up -d
docker stop quartz-wiki
```
On first run, the container will download the necessary dependencies, build the site, and download the content repository.
You will also need to
On first run, the container will download the necessary dependencies and build the site.
In `/srv/quartz/config/config.json`, you need to change the `baseUrl` to your domain.
## ⚙️ Configuration
@ -48,12 +62,10 @@ To keep the image small, `node_modules` are not included. When the container is
This is the command run by cron
```bash
cd /quartz/content
git restore .
git pull
cd /quartz/src &
npx quartz build
echo 'Content Updated.'
cd /usr/share/nginx/html/content && \
git pull >/dev/null 2>&1 && \
cd /usr/share/nginx/html && \
npx quartz build >/dev/null 2>&1
```
Setting `ENABLE_CRON` to `true` and defining `BUILD_SCHEDULE` performs these actions.
@ -63,18 +75,22 @@ Example:
```yaml
environment:
ENABLE_CRON: "true"
ENABLE_CRON: true
BUILD_SCHEDULE: "*/1 * * * *" # Runs every minute
```
### Environment Variables
| Variable | Description | Default Value |
| ---------------- | ----------------------------------------------------- | ----------------------------- |
| `USER_ID` | UID that` /content` and` /config` will be chown'd to. | `1000` |
| `GROUP_ID` | GID that` /content` and` /config` will be chown'd to. | `1000` |
| `NGINX_PORT` | Port for the Nginx server | `80` |
| `SERVER_NAME` | NGINX server name | `quartz.zhao.xyz` |
| `ENABLE_CRON` | Enables scheduled builds (`true` or `false`) | `false` |
| `BUILD_SCHEDULE` | Cron expression for scheduling site builds | `"*/10 * * * *"` every 10 min |
| `CONTENT_REPO` | URL of the content repository | |
See a list of all environment variables [here](#environment-variables).
| Variable | Description | Default Value |
| -------------------- | ----------------------------------------------------- | ----------------------------- |
| `NGINX_PORT` | Port for the Nginx server | `80` |
| `SERVER_NAME` | NGINX server name | `quartz.zhao.xyz` |
| `ENABLE_CRON` | Enables scheduled builds (`true` or `false`) | `false` |
| `BUILD_SCHEDULE` | Cron expression for scheduling site builds | `"*/10 * * * *"` every 10 min |
| `QUARTZ_CONFIG_PATH` | Path to the Quartz configuration file | `/config/quartz.json` |
| `USER_ID` | UID that` /content` and` /config` will be chown'd to. | `1000` |
| `GROUP_ID` | GID that` /content` and` /config` will be chown'd to. | `1000` |
You shouldn't need to change `QUARTZ_CONFIG_PATH`

View file

@ -1,17 +1,15 @@
```yaml
services:
quartz-docker:
container_name: quartz-docker
image: code.modernleft.org/gravityfargo/quartz-docker:dev
quartz-wiki:
container_name: quartz-wiki
hostname: quartz-wiki
image: code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
ports:
- 80:80
- 80:80
environment:
USER_ID: 1000
GROUP_ID: 1001
SERVER_NAME: "docs.modernleft.org"
ENABLE_CRON: "true"
BUILD_SCHEDULE: "*/30 * * * *"
CONTENT_REPO: "https://code.modernleft.org/gravityfargo/modernleft-docs.git"
BUILD_SCHEDULE: "*/10 * * * *"
volumes:
- /srv/quartz:/quartz
- /srv/quartz/content:/quartz
```