summaryrefslogtreecommitdiff
path: root/README.md
blob: f9ed7999bfe3663120d74522ea18e72c9f72df24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Witryna

Witryna is a minimalist Git-based static site deployment orchestrator.
It listens for webhook triggers, pulls Git repositories, runs
containerized build commands, and publishes static assets via atomic
symlink switching.

## How it works

A webhook POST triggers Witryna to pull a Git repository (with
automatic submodule initialization and Git LFS fetch), run a build
command inside a container, copy the output to a timestamped directory,
and atomically switch a symlink to the new build.
Your web server serves files from the symlink — zero-downtime deploys.

## Install

Pre-built packages are available at
[release.craftknight.com](https://release.craftknight.com/).

From a `.deb` package (Debian/Ubuntu):

    curl -LO https://release.craftknight.com/witryna_0.1.0-1_amd64.deb
    sudo dpkg -i witryna_0.1.0-1_amd64.deb

From an `.rpm` package (Fedora/RHEL):

    curl -LO https://release.craftknight.com/witryna-0.1.0-1.x86_64.rpm
    sudo rpm -i witryna-0.1.0-1.x86_64.rpm

From a tarball (any Linux):

    curl -LO https://release.craftknight.com/witryna-0.1.0-linux-amd64.tar.gz
    tar xzf witryna-0.1.0-linux-amd64.tar.gz
    sudo cp witryna-0.1.0-linux-amd64/witryna /usr/local/bin/

From source:

    cargo install --path .

## Post-install

The deb/rpm packages automatically detect your container runtime:

- **Docker**: `witryna` user added to `docker` group, systemd override installed
- **Podman**: subuids/subgids allocated, lingering enabled, systemd override installed
- **Neither found**: warning with instructions

If you install a runtime later, reinstall the package or manually copy the
override from `/usr/share/doc/witryna/examples/systemd/` to
`/etc/systemd/system/witryna.service.d/10-runtime.conf` and run
`sudo systemctl daemon-reload`.

## Quickstart

1. Create `/etc/witryna/witryna.toml`:

    ```toml
    listen_address = "127.0.0.1:8080"
    container_runtime = "podman"
    base_dir = "/var/lib/witryna"
    log_level = "info"

    [[sites]]
    name = "my-site"
    repo_url = "https://github.com/user/my-site.git"
    branch = "main"
    webhook_token = "YOUR_TOKEN"  # omit to disable auth
    ```

2. Add a build config to the root of your Git repository (`.witryna.yaml`,
   `.witryna.yml`, `witryna.yaml`, or `witryna.yml`):

    ```yaml
    image: node:20-alpine
    command: "npm ci && npm run build"
    public: dist
    ```

3. Start Witryna:

    ```
    witryna serve
    ```

4. Trigger a build:

    ```
    TOKEN=...  # your webhook_token from witryna.toml
    curl -X POST -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8080/my-site
    # If webhook_token is omitted, the -H header is not needed.
    ```

## CLI

| Command | Description |
|---------|-------------|
| `witryna serve` | Start the deployment server |
| `witryna validate` | Validate config and print summary |
| `witryna run <site>` | Run a one-off build (synchronous) |
| `witryna status` | Show deployment status |

## Configuration

Witryna searches for its config file automatically: `./witryna.toml`,
`$XDG_CONFIG_HOME/witryna/witryna.toml`, `/etc/witryna/witryna.toml`.
Use `--config` to specify an explicit path.

See `witryna.toml(5)` for the full configuration reference:

    man witryna.toml

Build config supports `.witryna.yaml`, `.witryna.yml`, `witryna.yaml`, and
`witryna.yml` (searched in that order). See `examples/` for annotated files.

## Reverse proxy

Point your web server's document root at
`/var/lib/witryna/builds/<site>/current` and reverse-proxy webhook
requests to Witryna. See `examples/caddy/` and `examples/nginx/` for
ready-to-use configurations.

## Building from source

    cargo build --release

Development uses [just](https://github.com/casey/just) as a command runner:

    cargo install just    # or: pacman -S just / brew install just

Key recipes:

    just test             # unit tests
    just test-all         # lints + unit + integration tests
    just lint             # fmt check + clippy + yamllint + gitleaks

To build distribution packages:

    just build-deb    # Debian .deb package
    just build-rpm    # RPM package

## Dependencies

- Rust 1.85+ (build only)
- Git
- Podman or Docker

## License

MIT — see LICENSE for details.