Skip to content

Commit 70c248f

Browse files
author
Kevin Wang
committed
docs(dstack-ingress): name the ACME account settings after ACME, not certbot
1 parent cde5449 commit 70c248f

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

custom-domain/dstack-ingress/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ environment:
159159
| `DOMAIN` | Your domain (single-domain mode). Supports wildcards (`*.example.com`) |
160160
| `TARGET_ENDPOINT` | Backend address, e.g. `app:80` or `http://app:80` |
161161
| `GATEWAY_DOMAIN` | dstack gateway domain (e.g. `_.dstack-prod5.phala.network`) |
162-
| `CERTBOT_EMAIL` | Email for Let's Encrypt registration |
162+
| `CERTBOT_EMAIL` | Email for Let's Encrypt registration. In tls-alpn-01 mode the preferred name is `ACME_EMAIL` |
163163
| `DNS_PROVIDER` | DNS provider (`cloudflare`, `linode`, `namecheap`) |
164164

165165
### Optional
@@ -171,7 +171,8 @@ environment:
171171
| `ROUTING_MAP` | | Multi-domain routing: `domain=host:port` per line |
172172
| `SET_CAA` | `false` | Enable CAA DNS record (dns-01 only; tls-alpn-01 cannot write DNS) |
173173
| `TXT_PREFIX` | `_dstack-app-address` | DNS TXT record prefix |
174-
| `CERTBOT_STAGING` | `false` | Use Let's Encrypt staging server |
174+
| `CERTBOT_STAGING` | `false` | Use Let's Encrypt staging server. `ACME_STAGING` is the preferred name in tls-alpn-01 mode |
175+
| `ACME_EMAIL` | | ACME account email in tls-alpn-01 mode. Falls back to `CERTBOT_EMAIL`; there is no certbot on that path |
175176
| `CHALLENGE_TYPE` | `dns-01` | `dns-01` (certbot + DNS credentials) or `tls-alpn-01` (lego, no DNS credentials) |
176177
| `DNS_SETUP_MODE` | `wait` | tls-alpn-01 only: `wait`, `print` or `webhook` — see below |
177178
| `DNS_SETUP_TIMEOUT` | `1800` | tls-alpn-01 only: seconds to wait for the records to appear |
@@ -253,8 +254,10 @@ services:
253254
- CHALLENGE_TYPE=tls-alpn-01
254255
- DOMAIN=app.example.com
255256
- TARGET_ENDPOINT=http://app:80
257+
# Printed as the CNAME target, and used to verify that the hostname
258+
# really resolves to the gateway before issuance starts.
256259
- GATEWAY_DOMAIN=_.dstack-prod5.phala.network
257-
- CERTBOT_EMAIL=you@example.com
260+
- ACME_EMAIL=you@example.com
258261
# - DNS_SETUP_MODE=wait # default; blocks until the records exist
259262
ports:
260263
- "443:443"

custom-domain/dstack-ingress/scripts/legoman.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@
4747

4848

4949
def acme_server() -> str:
50-
if os.environ.get("CERTBOT_STAGING", "false") == "true":
51-
return ACME_STAGING
52-
return ACME_PROD
50+
# CERTBOT_STAGING is the historical name and still works, but there is no
51+
# certbot on this path: the ACME client here is lego.
52+
staging = os.environ.get("ACME_STAGING") or os.environ.get("CERTBOT_STAGING", "false")
53+
return ACME_STAGING if staging == "true" else ACME_PROD
5354

5455

5556
def server_dir() -> str:
@@ -210,11 +211,11 @@ def main() -> int:
210211
parser.add_argument("--email", help="Email for ACME registration")
211212
args = parser.parse_args()
212213

213-
email = args.email or os.environ.get("CERTBOT_EMAIL", "")
214+
email = args.email or os.environ.get("ACME_EMAIL") or os.environ.get("CERTBOT_EMAIL", "")
214215

215216
if args.action == "account-uri":
216217
if not email:
217-
print("Error: --email or CERTBOT_EMAIL is required", file=sys.stderr)
218+
print("Error: --email or ACME_EMAIL is required", file=sys.stderr)
218219
return EXIT_ERROR
219220
uri = account_uri(email)
220221
if not uri:
@@ -231,7 +232,7 @@ def main() -> int:
231232
return EXIT_CHANGED
232233

233234
if not email:
234-
print("Error: --email or CERTBOT_EMAIL is required", file=sys.stderr)
235+
print("Error: --email or ACME_EMAIL is required", file=sys.stderr)
235236
return EXIT_ERROR
236237
if not os.path.isfile(LEGO_BIN):
237238
print(f"Error: lego binary not found at {LEGO_BIN}", file=sys.stderr)

custom-domain/dstack-ingress/scripts/tlsalpn.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ source /scripts/functions.sh
1212
source /scripts/haproxy-lib.sh
1313
source /scripts/evidence-lib.sh
1414

15+
# ACME account settings. CERTBOT_EMAIL / CERTBOT_STAGING are the historical
16+
# names, kept working for anyone migrating a compose file from dns-01, but there
17+
# is no certbot on this path -- the ACME client here is lego.
18+
ACME_EMAIL=${ACME_EMAIL:-${CERTBOT_EMAIL:-}}
19+
ACME_STAGING=${ACME_STAGING:-${CERTBOT_STAGING:-false}}
20+
export ACME_EMAIL ACME_STAGING
21+
22+
if [ -z "$ACME_EMAIL" ]; then
23+
echo "Error: ACME_EMAIL must be set (CERTBOT_EMAIL is accepted as an alias)" >&2
24+
exit 1
25+
fi
26+
1527
LEGO_BIN=${LEGO_BIN:-/usr/local/bin/lego}
1628
LEGO_PATH=${LEGO_PATH:-/etc/letsencrypt/lego}
1729
TLSALPN_ADDRESS=${TLSALPN_ADDRESS:-127.0.0.1}
@@ -182,13 +194,13 @@ process_domain() {
182194
# Register the ACME account first so the CAA record we print can already
183195
# pin accounturi. Without this the operator would have to add CAA in a
184196
# second pass, after the account exists.
185-
if ! legoman.py register --email "$CERTBOT_EMAIL"; then
197+
if ! legoman.py register --email "$ACME_EMAIL"; then
186198
echo "Error: failed to register the ACME account" >&2
187199
exit 1
188200
fi
189201

190202
local account_uri caa_value
191-
account_uri=$(legoman.py account-uri --email "$CERTBOT_EMAIL" 2>/dev/null || true)
203+
account_uri=$(legoman.py account-uri --email "$ACME_EMAIL" 2>/dev/null || true)
192204
if [ -n "$account_uri" ]; then
193205
caa_value="letsencrypt.org;validationmethods=tls-alpn-01;accounturi=$account_uri"
194206
else
@@ -232,7 +244,7 @@ process_domain() {
232244
sleep "${DNS_SETTLE_SECONDS}"
233245
fi
234246

235-
legoman.py auto --domain "$domain" --email "$CERTBOT_EMAIL"
247+
legoman.py auto --domain "$domain" --email "$ACME_EMAIL"
236248
}
237249

238250
# One pass over every domain: make sure the records exist, then issue or renew.

0 commit comments

Comments
 (0)