modernleft-docs/Applications/quartz-docker.md

100 lines
3.2 KiB
Markdown
Raw Normal View History

2025-01-17 02:28:51 +00:00
---
title: quartz-docker
draft: false
date: 2025-01-16
---
2025-01-17 16:50:09 +00:00
2025-01-17 15:45:13 +00:00
[quartz-docker image](https://code.modernleft.org/gravityfargo/-/packages/container/quartz-docker/v4.4.0)
2025-01-17 15:48:51 +00:00
2025-01-17 16:24:01 +00:00
```bash
docker pull code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
```
2025-01-17 03:07:26 +00:00
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.
2025-01-17 16:51:51 +00:00
While Quartz provides [Docker support](https://quartz.jzhao.xyz/features/Docker-Support), it requires additional configuration. This container simplifies the process significantly.
2025-01-17 16:50:09 +00:00
2025-01-17 03:07:26 +00:00
## 🚀 Features
2025-01-17 16:55:12 +00:00
- **Easy Configuration** Customize settings using environment variables
- **Automated Site Updates** Configurable cron job to fetch and rebuild content
2025-01-17 15:48:51 +00:00
2025-01-17 03:07:26 +00:00
## 🛠️ Getting Started
2025-01-17 16:24:01 +00:00
### 🐳 Docker Compose
2025-01-17 03:07:26 +00:00
2025-01-17 16:50:09 +00:00
1. Create a data directory and pull your existing content:
2025-01-17 15:59:26 +00:00
```bash
git clone https://code.modernleft.org/gravityfargo/modernleft-docs.git quartz
```
2025-01-17 16:50:09 +00:00
2. Create a `docker-compose.yml` file:
#### Minimal Example
```yaml
version: "3"
services:
quartz:
image: code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
environment:
- BASE_URL=https://example.com
volumes:
- ./quartz:/usr/share/nginx/html
ports:
- "80:80"
```
2025-01-17 16:18:00 +00:00
2025-01-17 16:50:09 +00:00
##### `BASE_URL`
2025-01-17 16:18:00 +00:00
2025-01-17 16:50:09 +00:00
The only required variable is `BASE_URL`. This sets both Quartz's `baseUrl` and Nginx's `server_name`.
2025-01-17 16:18:00 +00:00
2025-01-17 16:50:09 +00:00
#### Recommended Setup
```yaml
version: "3"
services:
quartz:
image: code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
environment:
- BASE_URL=https://example.com
- ENABLE_CRON=true
- BUILD_SCHEDULE="0 * * * *"
volumes:
- ./quartz:/usr/share/nginx/html
- node_modules:/usr/share/nginx/html/node_modules
ports:
- "80:80"
volumes:
node_modules:
```
##### Persistent `node_modules` Volume
To keep the image small, `node_modules` are not included. When the container is run, they are downloaded to `/usr/share/nginx/html/node_modules`. Mounting this as a volume ensures they persist between container runs, reducing setup time.
2025-01-17 15:59:26 +00:00
2025-01-17 16:50:09 +00:00
##### Enabling Cron Jobs
2025-01-17 16:18:00 +00:00
2025-01-17 16:51:51 +00:00
Setting `ENABLE_CRON` to `true` and defining `BUILD_SCHEDULE` as a cron expression allows `npx quartz build` to run on a schedule. That command pulls the latest content and rebuilds the site.
2025-01-17 03:07:26 +00:00
2025-01-17 16:50:09 +00:00
Example:
```yaml
environment:
- ENABLE_CRON=true
- BUILD_SCHEDULE=" * * * *" # Runs every hour
```
2025-01-17 16:18:00 +00:00
2025-01-17 16:50:09 +00:00
## 📌 Environment Variables
2025-01-17 16:18:00 +00:00
2025-01-17 16:51:51 +00:00
See a list of all environment variables [here](#environment-variables).
2025-01-17 16:50:09 +00:00
| Variable | Description | Default Value |
| ---------------- | -------------------------------------------- | ------------------------------- |
| `BASE_URL` | The base URL for the site (Required) | None |
| `ENABLE_CRON` | Enables scheduled builds (`true` or `false`) | `false` |
| `BUILD_SCHEDULE` | Cron expression for scheduling site builds | `0 0 * * *` (Daily at midnight) |
2025-01-17 16:18:00 +00:00
2025-01-17 16:50:09 +00:00
This setup ensures a fully automated Quartz deployment with minimal configuration.