v2.31.0-dev5 4162c86

concepts.md RawHistoryFolder

Core Concepts

Understanding how Gordon works and why it's designed this way.

Local-First Development

Your development machine likely has 8-16 cores and 16-32GB RAM. Your VPS has 1-2 cores and 1-4GB RAM. Why build containers on the weak machine?

Gordon flips the typical deployment model:

  1. Build locally where you have computing power
  2. Push the finished image to your VPS
  3. Gordon deploys automatically

This means faster builds, less VPS resource usage, and a simpler deployment workflow.

Push-to-Deploy

Gordon combines a Docker registry with automatic deployment:

┌──────────────┐      push       ┌──────────────┐
│ docker build │  ──────────────>│   Gordon     │
│ docker push  │                 │   Registry   │
└──────────────┘                 └──────┬───────┘
                                        │
                                        │ event: image.pushed
                                        v
                                 ┌──────────────┐
                                 │   Deploy     │
                                 │   Container  │
                                 └──────────────┘

When you push an image, Gordon:

  1. Stores the image in its registry
  2. Fires an image.pushed event
  3. Looks up the route for that image
  4. Deploys a new container
  5. Updates the proxy routing
  6. Stops the old container

Zero-Downtime Updates

Gordon ensures your app stays available during updates:

  1. New container starts while old container is still running
  2. Health check waits for new container to be ready
  3. Traffic switches to the new container
  4. Old container stops after traffic has moved
Time ─────────────────────────────────────────────>

Old Container:  [═══════════════════]
                                    ↓ stop
New Container:           [═════════════════════════>
                         ↑ start    ↑ traffic routed

Routes

Routes map domains to container images:

[routes]
"app.mydomain.com" = "myapp:latest"
"api.mydomain.com" = "myapi:v2.1.0"

When a request comes in for app.mydomain.com, Gordon:

  1. Looks up the route configuration
  2. Finds the running container for myapp:latest
  3. Proxies the request to that container

HTTP vs HTTPS Routes

By default, routes expect HTTPS (terminated by Cloudflare). For HTTP-only routes:

[routes]
"http://internal.local" = "internal-app:latest"

Network Isolation

Each app runs in its own isolated Docker network:

┌────────────────────────────────────────────────┐
│ gordon-app-mydomain-com                        │
│                                                │
│  ┌──────────┐    ┌──────────┐    ┌──────────┐  │
│  │   App    │───>│ Postgres │    │  Redis   │  │
│  │ :3000    │    │ :5432    │    │ :6379    │  │
│  └──────────┘    └──────────┘    └──────────┘  │
│                                                │
└────────────────────────────────────────────────┘

Benefits:

  • Containers can't access each other's services
  • Services are only accessible by name within their network
  • No port conflicts between apps

Attachments

Attachments are service dependencies for your apps:

[attachments]
"app.mydomain.com" = ["postgres:latest", "redis:latest"]

Gordon deploys attachments to the same network as your app. Services are accessible by their image name:

// In your app
const db = await connect("postgresql://postgres:5432/mydb");
const cache = await connect("redis://redis:6379");

Network Groups

Network groups allow multiple apps to share services:

[network_groups]
"backend" = ["app.mydomain.com", "api.mydomain.com"]

[attachments]
"backend" = ["shared-postgres:latest", "shared-redis:latest"]

Both app.mydomain.com and api.mydomain.com can access the shared services.

Volumes

Gordon automatically creates persistent storage from Dockerfile VOLUME directives:

FROM postgres:18
VOLUME ["/var/lib/postgresql/data"]

Volume behavior:

  • auto_create: Volumes are created automatically (default: true)
  • prefix: Volume names are prefixed with gordon- (configurable)
  • preserve: Volumes persist across container updates (default: true)

Environment Variables

Gordon loads environment variables from files based on the domain:

~/.gordon/env/
├── app_mydomain_com.env
├── api_mydomain_com.env
└── admin_mydomain_com.env

Domain dots become underscores: app.mydomain.com → app_mydomain_com.env

Variables are merged in order:

  1. Dockerfile ENV directives (lowest priority)
  2. .env file values (highest priority)

Secret Providers

Environment files support secret provider syntax:

# From Unix password manager (pass)
DATABASE_PASSWORD=${pass:myapp/db-password}

# From SOPS encrypted files
API_SECRET=${sops:secrets.yaml:api.secret}

Configuration Hot-Reload

Gordon watches its config file and reloads automatically:

  1. Edit ~/.config/gordon/gordon.toml
  2. Save the file
  3. Gordon reloads routes, attachments, and network groups
  4. Containers sync to match new configuration

You can also trigger a manual reload:

gordon reload

This sends SIGUSR1 to the running Gordon process.

Event System

Gordon uses an internal event system for coordination:

Event Trigger Action
image.pushed Image pushed to registry Deploy container
config.reload Config file changed Sync containers
manual.reload gordon reload command Sync containers
manual.deploy gordon deploy <domain> command Deploy specific route
container.deployed Container started Update proxy cache

Backups and Recovery

Gordon can run logical PostgreSQL backups for attachment containers.

Current design:

  1. Detect PostgreSQL attachments attached to a route
  2. Execute pg_dump -Fc through Gordon runtime operations
  3. Store backup artifacts on local filesystem storage
  4. Expose backup actions through admin API and CLI

This is intentionally scoped for operational safety and predictable behavior. Future extensions can add physical backups, PITR, and remote object storage adapters. For configuration details and usage examples, see the Backups Configuration guide, Backup CLI reference, and Configuration Reference.

Container Labels

Gordon uses labels to track managed containers:

Label Purpose
gordon.managed=true Identifies Gordon-managed containers
gordon.domain Domain this container serves
gordon.image Image name and tag
gordon.route Route this container handles
gordon.attachment=true Container is an attachment service
gordon.attached-to Which route this attachment serves

Proxy Port Selection

When a container exposes multiple ports, Gordon needs to know which one serves HTTP:

FROM gitea/gitea:latest
LABEL gordon.proxy.port=3000  # Route HTTP to port 3000
EXPOSE 22   # SSH
EXPOSE 3000 # HTTP

Without the label, Gordon uses the first exposed port.

source
1# Core Concepts
2
3Understanding how Gordon works and why it's designed this way.
4
5## Local-First Development
6
7Your development machine likely has 8-16 cores and 16-32GB RAM. Your VPS has 1-2 cores and 1-4GB RAM. Why build containers on the weak machine?
8
9Gordon flips the typical deployment model:
10
111. **Build locally** where you have computing power
122. **Push the finished image** to your VPS
133. **Gordon deploys automatically**
14
15This means faster builds, less VPS resource usage, and a simpler deployment workflow.
16
17## Push-to-Deploy
18
19Gordon combines a Docker registry with automatic deployment:
20
21```
22┌──────────────┐      push       ┌──────────────┐
23│ docker build │  ──────────────>│   Gordon     │
24│ docker push  │                 │   Registry   │
25└──────────────┘                 └──────┬───────┘
26                                        │
27                                        │ event: image.pushed
28                                        v
29                                 ┌──────────────┐
30                                 │   Deploy     │
31                                 │   Container  │
32                                 └──────────────┘
33```
34
35When you push an image, Gordon:
36
371. Stores the image in its registry
382. Fires an `image.pushed` event
393. Looks up the route for that image
404. Deploys a new container
415. Updates the proxy routing
426. Stops the old container
43
44## Zero-Downtime Updates
45
46Gordon ensures your app stays available during updates:
47
481. **New container starts** while old container is still running
492. **Health check** waits for new container to be ready
503. **Traffic switches** to the new container
514. **Old container stops** after traffic has moved
52
53```
54Time ─────────────────────────────────────────────>
55
56Old Container:  [═══════════════════]
57                                    ↓ stop
58New Container:           [═════════════════════════>
59                         ↑ start    ↑ traffic routed
60```
61
62## Routes
63
64Routes map domains to container images:
65
66```toml
67[routes]
68"app.mydomain.com" = "myapp:latest"
69"api.mydomain.com" = "myapi:v2.1.0"
70```
71
72When a request comes in for `app.mydomain.com`, Gordon:
73
741. Looks up the route configuration
752. Finds the running container for `myapp:latest`
763. Proxies the request to that container
77
78### HTTP vs HTTPS Routes
79
80By default, routes expect HTTPS (terminated by Cloudflare). For HTTP-only routes:
81
82```toml
83[routes]
84"http://internal.local" = "internal-app:latest"
85```
86
87## Network Isolation
88
89Each app runs in its own isolated Docker network:
90
91```
92┌────────────────────────────────────────────────┐
93│ gordon-app-mydomain-com                        │
94│                                                │
95│  ┌──────────┐    ┌──────────┐    ┌──────────┐  │
96│  │   App    │───>│ Postgres │    │  Redis   │  │
97│  │ :3000    │    │ :5432    │    │ :6379    │  │
98│  └──────────┘    └──────────┘    └──────────┘  │
99│                                                │
100└────────────────────────────────────────────────┘
101```
102
103Benefits:
104
105- Containers can't access each other's services
106- Services are only accessible by name within their network
107- No port conflicts between apps
108
109## Attachments
110
111Attachments are service dependencies for your apps:
112
113```toml
114[attachments]
115"app.mydomain.com" = ["postgres:latest", "redis:latest"]
116```
117
118Gordon deploys attachments to the same network as your app. Services are accessible by their image name:
119
120```javascript
121// In your app
122const db = await connect("postgresql://postgres:5432/mydb");
123const cache = await connect("redis://redis:6379");
124```
125
126## Network Groups
127
128Network groups allow multiple apps to share services:
129
130```toml
131[network_groups]
132"backend" = ["app.mydomain.com", "api.mydomain.com"]
133
134[attachments]
135"backend" = ["shared-postgres:latest", "shared-redis:latest"]
136```
137
138Both `app.mydomain.com` and `api.mydomain.com` can access the shared services.
139
140## Volumes
141
142Gordon automatically creates persistent storage from Dockerfile `VOLUME` directives:
143
144```dockerfile
145FROM postgres:18
146VOLUME ["/var/lib/postgresql/data"]
147```
148
149Volume behavior:
150
151- **auto_create**: Volumes are created automatically (default: true)
152- **prefix**: Volume names are prefixed with `gordon-` (configurable)
153- **preserve**: Volumes persist across container updates (default: true)
154
155## Environment Variables
156
157Gordon loads environment variables from files based on the domain:
158
159```
160~/.gordon/env/
161├── app_mydomain_com.env
162├── api_mydomain_com.env
163└── admin_mydomain_com.env
164```
165
166Domain dots become underscores: `app.mydomain.com` → `app_mydomain_com.env`
167
168Variables are merged in order:
169
1701. Dockerfile `ENV` directives (lowest priority)
1712. `.env` file values (highest priority)
172
173### Secret Providers
174
175Environment files support secret provider syntax:
176
177```bash
178# From Unix password manager (pass)
179DATABASE_PASSWORD=${pass:myapp/db-password}
180
181# From SOPS encrypted files
182API_SECRET=${sops:secrets.yaml:api.secret}
183```
184
185## Configuration Hot-Reload
186
187Gordon watches its config file and reloads automatically:
188
1891. Edit `~/.config/gordon/gordon.toml`
1902. Save the file
1913. Gordon reloads routes, attachments, and network groups
1924. Containers sync to match new configuration
193
194You can also trigger a manual reload:
195
196```bash
197gordon reload
198```
199
200This sends `SIGUSR1` to the running Gordon process.
201
202## Event System
203
204Gordon uses an internal event system for coordination:
205
206| Event | Trigger | Action |
207|-------|---------|--------|
208| `image.pushed` | Image pushed to registry | Deploy container |
209| `config.reload` | Config file changed | Sync containers |
210| `manual.reload` | `gordon reload` command | Sync containers |
211| `manual.deploy` | `gordon deploy <domain>` command | Deploy specific route |
212| `container.deployed` | Container started | Update proxy cache |
213
214## Backups and Recovery
215
216Gordon can run logical PostgreSQL backups for attachment containers.
217
218Current design:
219
2201. Detect PostgreSQL attachments attached to a route
2212. Execute `pg_dump -Fc` through Gordon runtime operations
2223. Store backup artifacts on local filesystem storage
2234. Expose backup actions through admin API and CLI
224
225This is intentionally scoped for operational safety and predictable behavior.
226Future extensions can add physical backups, PITR, and remote object storage adapters.
227For configuration details and usage examples, see the [Backups Configuration guide](./config/backups.md), [Backup CLI reference](./cli/backup.md), and [Configuration Reference](./config/reference.md).
228
229## Container Labels
230
231Gordon uses labels to track managed containers:
232
233| Label | Purpose |
234|-------|---------|
235| `gordon.managed=true` | Identifies Gordon-managed containers |
236| `gordon.domain` | Domain this container serves |
237| `gordon.image` | Image name and tag |
238| `gordon.route` | Route this container handles |
239| `gordon.attachment=true` | Container is an attachment service |
240| `gordon.attached-to` | Which route this attachment serves |
241
242## Proxy Port Selection
243
244When a container exposes multiple ports, Gordon needs to know which one serves HTTP:
245
246```dockerfile
247FROM gitea/gitea:latest
248LABEL gordon.proxy.port=3000  # Route HTTP to port 3000
249EXPOSE 22   # SSH
250EXPOSE 3000 # HTTP
251```
252
253Without the label, Gordon uses the first exposed port.
254
255## Related
256
257- [Configuration Reference](./config/index.md)
258- [Docker Labels Reference](./reference/docker-labels.md)
259- [Environment Variables](./config/env.md) 

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close