vibed-infra 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibed-infra",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Product-agnostic VPS packager: wget install, Docker Compose, TLS/nginx, auto-update",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -55,7 +55,7 @@ cd ~/services/gateway
55
55
  ./setup-tls.sh --force # re-issue after host or IP change
56
56
  ```
57
57
 
58
- - **Production:** `setup-tls.sh` issues Let’s Encrypt via docker `certbot/certbot` by default (config under `$GATEWAY_HOME/letsencrypt`, PEMs copied to `$GATEWAY_HOME/certs/`). No sudo required when Docker is available. Host certbot + sudo still preferred when present (same `--config-dir` under gateway home). Webroot if gateway is up, else standalone. On failure, fix DNS then re-run `setup-tls.sh`.
58
+ - **Production:** `setup-tls.sh` issues Let’s Encrypt via docker `certbot/certbot` by default (config under `$GATEWAY_HOME/letsencrypt`, PEMs installed into `$GATEWAY_HOME/certs/` — direct `cp` when readable, else alpine container copy+chown for root-owned `live/`). No sudo required when Docker is available. Host certbot + sudo still preferred when present (same `--config-dir` under gateway home). Webroot if gateway is up, else standalone. On failure, fix DNS then re-run `setup-tls.sh`.
59
59
  - **Lab/CI:** `TLS_MODE=lab` → multi-SAN self-signed under `./certs/`.
60
60
 
61
61
  ## Webhook path (immediate docker pull)
@@ -254,13 +254,33 @@ EOF
254
254
  return 0
255
255
  fi
256
256
 
257
- local live="${LE_HOME}/live/${primary}"
258
- if [[ ! -f "${live}/fullchain.pem" || ! -f "${live}/privkey.pem" ]]; then
259
- echo "certbot succeeded but ${live} PEMs missing" >&2
260
- return 1
261
- fi
262
- cp -L "${live}/fullchain.pem" "${CERT_DIR}/fullchain.pem"
263
- cp -L "${live}/privkey.pem" "${CERT_DIR}/privkey.pem"
257
+ # Copy PEMs into CERT_DIR without sudo. Docker certbot leaves root-owned live/
258
+ # (mode 700); host path may be readable after sudo chown above.
259
+ install_pems_to_certs() {
260
+ local primary="$1"
261
+ local live="${LE_HOME}/live/${primary}"
262
+ mkdir -p "$CERT_DIR"
263
+ if [[ -r "${live}/fullchain.pem" && -r "${live}/privkey.pem" ]]; then
264
+ cp -L "${live}/fullchain.pem" "${CERT_DIR}/fullchain.pem"
265
+ cp -L "${live}/privkey.pem" "${CERT_DIR}/privkey.pem"
266
+ elif command -v docker >/dev/null 2>&1; then
267
+ # certbot container wrote root-owned live/; copy+chown via alpine
268
+ docker run --rm \
269
+ -v "${LE_HOME}:/etc/letsencrypt:ro" \
270
+ -v "${CERT_DIR}:/out" \
271
+ "${CERTBOT_HELPER_IMAGE:-alpine:3.20}" \
272
+ sh -c "cp -L /etc/letsencrypt/live/${primary}/fullchain.pem /out/fullchain.pem && cp -L /etc/letsencrypt/live/${primary}/privkey.pem /out/privkey.pem && chown $(id -u):$(id -g) /out/fullchain.pem /out/privkey.pem && chmod 644 /out/fullchain.pem && chmod 600 /out/privkey.pem"
273
+ else
274
+ echo "Cannot read ${live} PEMs (root-owned?) and docker unavailable to copy them" >&2
275
+ return 1
276
+ fi
277
+ if [[ ! -f "${CERT_DIR}/fullchain.pem" || ! -f "${CERT_DIR}/privkey.pem" ]]; then
278
+ echo "Failed to install PEMs into ${CERT_DIR}" >&2
279
+ return 1
280
+ fi
281
+ }
282
+
283
+ install_pems_to_certs "$primary"
264
284
  chmod 644 "${CERT_DIR}/fullchain.pem"
265
285
  chmod 600 "${CERT_DIR}/privkey.pem"
266
286
  patch_env_key TLS_FULLCHAIN "${CERT_DIR}/fullchain.pem"