Compare commits
2 commits
82e0dedd79
...
5f7057ce22
Author | SHA1 | Date | |
---|---|---|---|
5f7057ce22 | |||
d87f05b698 |
1 changed files with 64 additions and 16 deletions
|
@ -3,6 +3,7 @@ title: quartz-docker
|
|||
draft: false
|
||||
date: 2025-01-16
|
||||
---
|
||||
|
||||
[quartz-docker image](https://code.modernleft.org/gravityfargo/-/packages/container/quartz-docker/v4.4.0)
|
||||
|
||||
```bash
|
||||
|
@ -11,42 +12,89 @@ docker pull code.modernleft.org/gravityfargo/quartz-docker:v4.4.0
|
|||
|
||||
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 requires additional configuration. This container simplifies the process significantly.
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
- configurable with environment variables
|
||||
- node and nginx included
|
||||
- configurable cron for job to pull and build site
|
||||
- Configurable with environment variables
|
||||
- Node.js and Nginx included
|
||||
- Configurable cron job to pull and build the site automatically
|
||||
|
||||
## 🛠️ Getting Started
|
||||
|
||||
### 🐳 Docker Compose
|
||||
|
||||
See a list of all Environment Variables [[environment variables|here.]]
|
||||
|
||||
1. Create a data directory and pull your existing content
|
||||
1. Create a data directory and pull your existing content:
|
||||
|
||||
```bash
|
||||
git clone https://code.modernleft.org/gravityfargo/modernleft-docs.git quartz
|
||||
```
|
||||
|
||||
2. Create a `docker-compose.yml` file
|
||||
2. Create a `docker-compose.yml` file:
|
||||
|
||||
#### Minimal
|
||||
#### Minimal Example
|
||||
|
||||
![[minimal docker-compose]]
|
||||
```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"
|
||||
```
|
||||
|
||||
##### `BASE_URL`
|
||||
|
||||
The only required variable is `BASE_URL`. The rest are set to the developer's [defaults](https://quartz.jzhao.xyz/configuration) `BASE_URL` sets both quartz's `baseUrl` as well as nginx's `server_name`.
|
||||
The only required variable is `BASE_URL`. This sets both Quartz's `baseUrl` and Nginx's `server_name`.
|
||||
|
||||
#### Recommended
|
||||
#### Recommended Setup
|
||||
|
||||
![[recommended docker-compose]]
|
||||
```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:
|
||||
```
|
||||
|
||||
##### node_modules volume
|
||||
##### Persistent `node_modules` Volume
|
||||
|
||||
To keep the image small, `node_modules` are not included. When the container is run, they're downloaded to `/usr/share/nginx/html/node_modules`. You should keep them in a volume so that the modules persist between container runs.
|
||||
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.
|
||||
|
||||
##### [[cron]]
|
||||
##### Enabling Cron Jobs
|
||||
|
||||
You should also set `ENABLE_CRON` to `true` and set `BUILD_SCHEDULE` to a cron expression to enable the schedule that `npx quartz build` is executed with. This will pull the latest content and build the site.
|
||||
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.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- ENABLE_CRON=true
|
||||
- BUILD_SCHEDULE=" * * * *" # Runs every hour
|
||||
```
|
||||
|
||||
## 📌 Environment Variables
|
||||
|
||||
See a list of all environment variables [here](#environment-variables).
|
||||
|
||||
| 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) |
|
||||
|
||||
This setup ensures a fully automated Quartz deployment with minimal configuration.
|
||||
|
|
Loading…
Reference in a new issue