Add staging + PR-preview environments on the flagship
Implements the staging-environments OpenSpec change. Persistent staging at staging.trails.cool / planner.staging.trails.cool deploys from main; PR opens get a journal-only preview at pr-<N>.staging.trails.cool that shares the persistent planner. cd-staging.yml builds tagged images, manages per-PR Postgres databases and Caddyfile snippets, evicts the oldest preview at the cap of 3, and tears everything down on PR close. staging-cleanup.yml runs weekly to sweep orphaned previews. DNS records (staging + *.staging A/AAAA) already applied to production via tofu. Caddy approach: per-PR Caddyfile snippets imported from /etc/caddy/sites/ and reloaded on each PR event — no wildcard / on-demand TLS, no router service. Production compose gains a trails-shared network for the staging project to reach Postgres, and host.docker.internal on Caddy so it can reverse-proxy staging containers published on the host loopback. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
795ec2215c
commit
c8a7a0b253
11 changed files with 818 additions and 29 deletions
|
|
@ -191,6 +191,42 @@ resource "hcloud_zone_rrset" "planner_aaaa" {
|
|||
records = [{ value = hcloud_server.trails.ipv6_address }]
|
||||
}
|
||||
|
||||
# Staging — persistent journal at staging.trails.cool, persistent planner
|
||||
# at planner.staging.trails.cool, and PR previews at pr-<N>.staging.trails.cool
|
||||
# (covered by the wildcard). All resolve to the flagship; Caddy routes per-host.
|
||||
|
||||
resource "hcloud_zone_rrset" "staging_a" {
|
||||
zone = "trails.cool"
|
||||
name = "staging"
|
||||
type = "A"
|
||||
ttl = 300
|
||||
records = [{ value = hcloud_server.trails.ipv4_address }]
|
||||
}
|
||||
|
||||
resource "hcloud_zone_rrset" "staging_aaaa" {
|
||||
zone = "trails.cool"
|
||||
name = "staging"
|
||||
type = "AAAA"
|
||||
ttl = 300
|
||||
records = [{ value = hcloud_server.trails.ipv6_address }]
|
||||
}
|
||||
|
||||
resource "hcloud_zone_rrset" "staging_wildcard_a" {
|
||||
zone = "trails.cool"
|
||||
name = "*.staging"
|
||||
type = "A"
|
||||
ttl = 300
|
||||
records = [{ value = hcloud_server.trails.ipv4_address }]
|
||||
}
|
||||
|
||||
resource "hcloud_zone_rrset" "staging_wildcard_aaaa" {
|
||||
zone = "trails.cool"
|
||||
name = "*.staging"
|
||||
type = "AAAA"
|
||||
ttl = 300
|
||||
records = [{ value = hcloud_server.trails.ipv6_address }]
|
||||
}
|
||||
|
||||
# Internal wildcard — all *.internal.trails.cool resolves to the server.
|
||||
# Caddy handles routing per-subdomain. No individual DNS entries needed
|
||||
# for internal services (Grafana, Prometheus, etc.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue