6 changed files with 179 additions and 26 deletions
41
bin/disinto
41
bin/disinto
|
|
@ -1488,17 +1488,30 @@ p.write_text(text)
|
||||||
touch "${FACTORY_ROOT}/.env"
|
touch "${FACTORY_ROOT}/.env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure Forgejo and Woodpecker subpath URLs when EDGE_TUNNEL_FQDN is set
|
# Configure Forgejo and Woodpecker URLs when EDGE_TUNNEL_FQDN is set.
|
||||||
|
# In subdomain mode, uses per-service FQDNs at root path instead of subpath URLs.
|
||||||
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
||||||
# Forgejo ROOT_URL with /forge/ subpath (note trailing slash - Forgejo needs it)
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
|
# Subdomain mode: Forgejo at forge.<project>.disinto.ai (root path)
|
||||||
|
if ! grep -q '^FORGEJO_ROOT_URL=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
||||||
|
echo "FORGEJO_ROOT_URL=https://${EDGE_TUNNEL_FQDN_FORGE:-forge.${EDGE_TUNNEL_FQDN}}/" >> "${FACTORY_ROOT}/.env"
|
||||||
|
fi
|
||||||
|
# Subdomain mode: Woodpecker at ci.<project>.disinto.ai (root path)
|
||||||
|
if ! grep -q '^WOODPECKER_HOST=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
||||||
|
echo "WOODPECKER_HOST=https://${EDGE_TUNNEL_FQDN_CI:-ci.${EDGE_TUNNEL_FQDN}}" >> "${FACTORY_ROOT}/.env"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Subpath mode: Forgejo ROOT_URL with /forge/ subpath (trailing slash required)
|
||||||
if ! grep -q '^FORGEJO_ROOT_URL=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
if ! grep -q '^FORGEJO_ROOT_URL=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
||||||
echo "FORGEJO_ROOT_URL=https://${EDGE_TUNNEL_FQDN}/forge/" >> "${FACTORY_ROOT}/.env"
|
echo "FORGEJO_ROOT_URL=https://${EDGE_TUNNEL_FQDN}/forge/" >> "${FACTORY_ROOT}/.env"
|
||||||
fi
|
fi
|
||||||
# Woodpecker WOODPECKER_HOST with /ci subpath (no trailing slash for v3)
|
# Subpath mode: Woodpecker WOODPECKER_HOST with /ci subpath (no trailing slash for v3)
|
||||||
if ! grep -q '^WOODPECKER_HOST=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
if ! grep -q '^WOODPECKER_HOST=' "${FACTORY_ROOT}/.env" 2>/dev/null; then
|
||||||
echo "WOODPECKER_HOST=https://${EDGE_TUNNEL_FQDN}/ci" >> "${FACTORY_ROOT}/.env"
|
echo "WOODPECKER_HOST=https://${EDGE_TUNNEL_FQDN}/ci" >> "${FACTORY_ROOT}/.env"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Prompt for FORGE_ADMIN_PASS before setup_forge
|
# Prompt for FORGE_ADMIN_PASS before setup_forge
|
||||||
# This ensures the password is set before Forgejo user creation
|
# This ensures the password is set before Forgejo user creation
|
||||||
|
|
@ -1603,9 +1616,15 @@ p.write_text(text)
|
||||||
create_woodpecker_oauth "$forge_url" "$forge_repo"
|
create_woodpecker_oauth "$forge_url" "$forge_repo"
|
||||||
|
|
||||||
# Create OAuth2 app on Forgejo for disinto-chat (#708)
|
# Create OAuth2 app on Forgejo for disinto-chat (#708)
|
||||||
|
# In subdomain mode, callback is at chat.<project> root instead of /chat/ subpath.
|
||||||
local chat_redirect_uri
|
local chat_redirect_uri
|
||||||
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
||||||
|
local chat_routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$chat_routing_mode" = "subdomain" ]; then
|
||||||
|
chat_redirect_uri="https://${EDGE_TUNNEL_FQDN_CHAT:-chat.${EDGE_TUNNEL_FQDN}}/oauth/callback"
|
||||||
|
else
|
||||||
chat_redirect_uri="https://${EDGE_TUNNEL_FQDN}/chat/oauth/callback"
|
chat_redirect_uri="https://${EDGE_TUNNEL_FQDN}/chat/oauth/callback"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
chat_redirect_uri="http://localhost/chat/oauth/callback"
|
chat_redirect_uri="http://localhost/chat/oauth/callback"
|
||||||
fi
|
fi
|
||||||
|
|
@ -2805,15 +2824,29 @@ disinto_edge() {
|
||||||
# Write to .env (replace existing entries to avoid duplicates)
|
# Write to .env (replace existing entries to avoid duplicates)
|
||||||
local tmp_env
|
local tmp_env
|
||||||
tmp_env=$(mktemp)
|
tmp_env=$(mktemp)
|
||||||
grep -Ev "^EDGE_TUNNEL_(HOST|PORT|FQDN)=" "$env_file" > "$tmp_env" 2>/dev/null || true
|
grep -Ev "^EDGE_TUNNEL_(HOST|PORT|FQDN|FQDN_FORGE|FQDN_CI|FQDN_CHAT)=" "$env_file" > "$tmp_env" 2>/dev/null || true
|
||||||
mv "$tmp_env" "$env_file"
|
mv "$tmp_env" "$env_file"
|
||||||
echo "EDGE_TUNNEL_HOST=${edge_host}" >> "$env_file"
|
echo "EDGE_TUNNEL_HOST=${edge_host}" >> "$env_file"
|
||||||
echo "EDGE_TUNNEL_PORT=${port}" >> "$env_file"
|
echo "EDGE_TUNNEL_PORT=${port}" >> "$env_file"
|
||||||
echo "EDGE_TUNNEL_FQDN=${fqdn}" >> "$env_file"
|
echo "EDGE_TUNNEL_FQDN=${fqdn}" >> "$env_file"
|
||||||
|
|
||||||
|
# Subdomain mode: write per-service FQDNs (#1028)
|
||||||
|
local reg_routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$reg_routing_mode" = "subdomain" ]; then
|
||||||
|
echo "EDGE_TUNNEL_FQDN_FORGE=forge.${fqdn}" >> "$env_file"
|
||||||
|
echo "EDGE_TUNNEL_FQDN_CI=ci.${fqdn}" >> "$env_file"
|
||||||
|
echo "EDGE_TUNNEL_FQDN_CHAT=chat.${fqdn}" >> "$env_file"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Registered: ${project}"
|
echo "Registered: ${project}"
|
||||||
echo " Port: ${port}"
|
echo " Port: ${port}"
|
||||||
echo " FQDN: ${fqdn}"
|
echo " FQDN: ${fqdn}"
|
||||||
|
if [ "$reg_routing_mode" = "subdomain" ]; then
|
||||||
|
echo " Mode: subdomain"
|
||||||
|
echo " Forge: forge.${fqdn}"
|
||||||
|
echo " CI: ci.${fqdn}"
|
||||||
|
echo " Chat: chat.${fqdn}"
|
||||||
|
fi
|
||||||
echo " Saved to: ${env_file}"
|
echo " Saved to: ${env_file}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ FORGE_URL = os.environ.get("FORGE_URL", "http://localhost:3000")
|
||||||
CHAT_OAUTH_CLIENT_ID = os.environ.get("CHAT_OAUTH_CLIENT_ID", "")
|
CHAT_OAUTH_CLIENT_ID = os.environ.get("CHAT_OAUTH_CLIENT_ID", "")
|
||||||
CHAT_OAUTH_CLIENT_SECRET = os.environ.get("CHAT_OAUTH_CLIENT_SECRET", "")
|
CHAT_OAUTH_CLIENT_SECRET = os.environ.get("CHAT_OAUTH_CLIENT_SECRET", "")
|
||||||
EDGE_TUNNEL_FQDN = os.environ.get("EDGE_TUNNEL_FQDN", "")
|
EDGE_TUNNEL_FQDN = os.environ.get("EDGE_TUNNEL_FQDN", "")
|
||||||
|
EDGE_TUNNEL_FQDN_CHAT = os.environ.get("EDGE_TUNNEL_FQDN_CHAT", "")
|
||||||
|
EDGE_ROUTING_MODE = os.environ.get("EDGE_ROUTING_MODE", "subpath")
|
||||||
|
|
||||||
# Shared secret for Caddy forward_auth verify endpoint (#709).
|
# Shared secret for Caddy forward_auth verify endpoint (#709).
|
||||||
# When set, only requests carrying this value in X-Forward-Auth-Secret are
|
# When set, only requests carrying this value in X-Forward-Auth-Secret are
|
||||||
|
|
@ -102,6 +104,8 @@ MIME_TYPES = {
|
||||||
|
|
||||||
def _build_callback_uri():
|
def _build_callback_uri():
|
||||||
"""Build the OAuth callback URI based on tunnel configuration."""
|
"""Build the OAuth callback URI based on tunnel configuration."""
|
||||||
|
if EDGE_ROUTING_MODE == "subdomain" and EDGE_TUNNEL_FQDN_CHAT:
|
||||||
|
return f"https://{EDGE_TUNNEL_FQDN_CHAT}/oauth/callback"
|
||||||
if EDGE_TUNNEL_FQDN:
|
if EDGE_TUNNEL_FQDN:
|
||||||
return f"https://{EDGE_TUNNEL_FQDN}/chat/oauth/callback"
|
return f"https://{EDGE_TUNNEL_FQDN}/chat/oauth/callback"
|
||||||
return "http://localhost/chat/oauth/callback"
|
return "http://localhost/chat/oauth/callback"
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ _create_forgejo_oauth_app() {
|
||||||
|
|
||||||
# Set up Woodpecker CI to use Forgejo as its forge backend.
|
# Set up Woodpecker CI to use Forgejo as its forge backend.
|
||||||
# Creates an OAuth2 app on Forgejo for Woodpecker, activates the repo.
|
# Creates an OAuth2 app on Forgejo for Woodpecker, activates the repo.
|
||||||
|
# Respects EDGE_ROUTING_MODE: in subdomain mode, uses EDGE_TUNNEL_FQDN_CI for redirect URI.
|
||||||
# Usage: create_woodpecker_oauth <forge_url> <repo_slug>
|
# Usage: create_woodpecker_oauth <forge_url> <repo_slug>
|
||||||
_create_woodpecker_oauth_impl() {
|
_create_woodpecker_oauth_impl() {
|
||||||
local forge_url="$1"
|
local forge_url="$1"
|
||||||
|
|
@ -150,7 +151,13 @@ _create_woodpecker_oauth_impl() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "── Woodpecker OAuth2 setup ────────────────────────────"
|
echo "── Woodpecker OAuth2 setup ────────────────────────────"
|
||||||
|
|
||||||
_create_forgejo_oauth_app "woodpecker-ci" "http://localhost:8000/authorize" || return 0
|
local wp_redirect_uri="http://localhost:8000/authorize"
|
||||||
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$routing_mode" = "subdomain" ] && [ -n "${EDGE_TUNNEL_FQDN_CI:-}" ]; then
|
||||||
|
wp_redirect_uri="https://${EDGE_TUNNEL_FQDN_CI}/authorize"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_create_forgejo_oauth_app "woodpecker-ci" "$wp_redirect_uri" || return 0
|
||||||
local client_id="${_OAUTH_CLIENT_ID}"
|
local client_id="${_OAUTH_CLIENT_ID}"
|
||||||
local client_secret="${_OAUTH_CLIENT_SECRET}"
|
local client_secret="${_OAUTH_CLIENT_SECRET}"
|
||||||
|
|
||||||
|
|
@ -158,10 +165,15 @@ _create_woodpecker_oauth_impl() {
|
||||||
# WP_FORGEJO_CLIENT/SECRET match the docker-compose.yml variable references
|
# WP_FORGEJO_CLIENT/SECRET match the docker-compose.yml variable references
|
||||||
# WOODPECKER_HOST must be host-accessible URL to match OAuth2 redirect_uri
|
# WOODPECKER_HOST must be host-accessible URL to match OAuth2 redirect_uri
|
||||||
local env_file="${FACTORY_ROOT}/.env"
|
local env_file="${FACTORY_ROOT}/.env"
|
||||||
|
local wp_host="http://localhost:8000"
|
||||||
|
if [ "$routing_mode" = "subdomain" ] && [ -n "${EDGE_TUNNEL_FQDN_CI:-}" ]; then
|
||||||
|
wp_host="https://${EDGE_TUNNEL_FQDN_CI}"
|
||||||
|
fi
|
||||||
|
|
||||||
local wp_vars=(
|
local wp_vars=(
|
||||||
"WOODPECKER_FORGEJO=true"
|
"WOODPECKER_FORGEJO=true"
|
||||||
"WOODPECKER_FORGEJO_URL=${forge_url}"
|
"WOODPECKER_FORGEJO_URL=${forge_url}"
|
||||||
"WOODPECKER_HOST=http://localhost:8000"
|
"WOODPECKER_HOST=${wp_host}"
|
||||||
)
|
)
|
||||||
if [ -n "${client_id:-}" ]; then
|
if [ -n "${client_id:-}" ]; then
|
||||||
wp_vars+=("WP_FORGEJO_CLIENT=${client_id}")
|
wp_vars+=("WP_FORGEJO_CLIENT=${client_id}")
|
||||||
|
|
|
||||||
|
|
@ -607,9 +607,12 @@ COMPOSEEOF
|
||||||
- EDGE_TUNNEL_USER=${EDGE_TUNNEL_USER:-tunnel}
|
- EDGE_TUNNEL_USER=${EDGE_TUNNEL_USER:-tunnel}
|
||||||
- EDGE_TUNNEL_PORT=${EDGE_TUNNEL_PORT:-}
|
- EDGE_TUNNEL_PORT=${EDGE_TUNNEL_PORT:-}
|
||||||
- EDGE_TUNNEL_FQDN=${EDGE_TUNNEL_FQDN:-}
|
- EDGE_TUNNEL_FQDN=${EDGE_TUNNEL_FQDN:-}
|
||||||
# Subdomain fallback (#713): if subpath routing (#704/#708) fails, add:
|
# Subdomain fallback (#1028): per-service FQDNs for subdomain routing mode.
|
||||||
# EDGE_TUNNEL_FQDN_FORGE, EDGE_TUNNEL_FQDN_CI, EDGE_TUNNEL_FQDN_CHAT
|
# Set EDGE_ROUTING_MODE=subdomain to activate. See docs/edge-routing-fallback.md.
|
||||||
# See docs/edge-routing-fallback.md for the full pivot plan.
|
- EDGE_ROUTING_MODE=${EDGE_ROUTING_MODE:-subpath}
|
||||||
|
- EDGE_TUNNEL_FQDN_FORGE=${EDGE_TUNNEL_FQDN_FORGE:-}
|
||||||
|
- EDGE_TUNNEL_FQDN_CI=${EDGE_TUNNEL_FQDN_CI:-}
|
||||||
|
- EDGE_TUNNEL_FQDN_CHAT=${EDGE_TUNNEL_FQDN_CHAT:-}
|
||||||
# Shared secret for Caddy ↔ chat forward_auth (#709)
|
# Shared secret for Caddy ↔ chat forward_auth (#709)
|
||||||
- FORWARD_AUTH_SECRET=${FORWARD_AUTH_SECRET:-}
|
- FORWARD_AUTH_SECRET=${FORWARD_AUTH_SECRET:-}
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -700,6 +703,8 @@ COMPOSEEOF
|
||||||
CHAT_OAUTH_CLIENT_ID: ${CHAT_OAUTH_CLIENT_ID:-}
|
CHAT_OAUTH_CLIENT_ID: ${CHAT_OAUTH_CLIENT_ID:-}
|
||||||
CHAT_OAUTH_CLIENT_SECRET: ${CHAT_OAUTH_CLIENT_SECRET:-}
|
CHAT_OAUTH_CLIENT_SECRET: ${CHAT_OAUTH_CLIENT_SECRET:-}
|
||||||
EDGE_TUNNEL_FQDN: ${EDGE_TUNNEL_FQDN:-}
|
EDGE_TUNNEL_FQDN: ${EDGE_TUNNEL_FQDN:-}
|
||||||
|
EDGE_TUNNEL_FQDN_CHAT: ${EDGE_TUNNEL_FQDN_CHAT:-}
|
||||||
|
EDGE_ROUTING_MODE: ${EDGE_ROUTING_MODE:-subpath}
|
||||||
DISINTO_CHAT_ALLOWED_USERS: ${DISINTO_CHAT_ALLOWED_USERS:-}
|
DISINTO_CHAT_ALLOWED_USERS: ${DISINTO_CHAT_ALLOWED_USERS:-}
|
||||||
# Shared secret for Caddy forward_auth verify endpoint (#709)
|
# Shared secret for Caddy forward_auth verify endpoint (#709)
|
||||||
FORWARD_AUTH_SECRET: ${FORWARD_AUTH_SECRET:-}
|
FORWARD_AUTH_SECRET: ${FORWARD_AUTH_SECRET:-}
|
||||||
|
|
@ -805,6 +810,11 @@ _generate_agent_docker_impl() {
|
||||||
# Output path: ${FACTORY_ROOT}/docker/Caddyfile (gitignored — generated artifact).
|
# Output path: ${FACTORY_ROOT}/docker/Caddyfile (gitignored — generated artifact).
|
||||||
# The edge compose service mounts this path as /etc/caddy/Caddyfile.
|
# The edge compose service mounts this path as /etc/caddy/Caddyfile.
|
||||||
# On a fresh clone, `disinto init` calls generate_caddyfile before first `disinto up`.
|
# On a fresh clone, `disinto init` calls generate_caddyfile before first `disinto up`.
|
||||||
|
#
|
||||||
|
# Routing mode (EDGE_ROUTING_MODE env var):
|
||||||
|
# subpath — (default) all services under <project>.disinto.ai/{forge,ci,chat,staging}
|
||||||
|
# subdomain — per-service subdomains: forge.<project>, ci.<project>, chat.<project>
|
||||||
|
# See docs/edge-routing-fallback.md for the full pivot plan.
|
||||||
_generate_caddyfile_impl() {
|
_generate_caddyfile_impl() {
|
||||||
local docker_dir="${FACTORY_ROOT}/docker"
|
local docker_dir="${FACTORY_ROOT}/docker"
|
||||||
local caddyfile="${docker_dir}/Caddyfile"
|
local caddyfile="${docker_dir}/Caddyfile"
|
||||||
|
|
@ -814,8 +824,22 @@ _generate_caddyfile_impl() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
|
||||||
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
|
_generate_caddyfile_subdomain "$caddyfile"
|
||||||
|
else
|
||||||
|
_generate_caddyfile_subpath "$caddyfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Created: ${caddyfile} (routing_mode=${routing_mode})"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Subpath Caddyfile: all services under a single :80 block with path-based routing.
|
||||||
|
_generate_caddyfile_subpath() {
|
||||||
|
local caddyfile="$1"
|
||||||
cat > "$caddyfile" <<'CADDYFILEEOF'
|
cat > "$caddyfile" <<'CADDYFILEEOF'
|
||||||
# Caddyfile — edge proxy configuration
|
# Caddyfile — edge proxy configuration (subpath mode)
|
||||||
# IP-only binding at bootstrap; domain + TLS added later via vault resource request
|
# IP-only binding at bootstrap; domain + TLS added later via vault resource request
|
||||||
|
|
||||||
:80 {
|
:80 {
|
||||||
|
|
@ -858,8 +882,50 @@ _generate_caddyfile_impl() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CADDYFILEEOF
|
CADDYFILEEOF
|
||||||
|
}
|
||||||
|
|
||||||
echo "Created: ${caddyfile}"
|
# Subdomain Caddyfile: four host blocks per docs/edge-routing-fallback.md.
|
||||||
|
# Uses env vars EDGE_TUNNEL_FQDN_FORGE, EDGE_TUNNEL_FQDN_CI, EDGE_TUNNEL_FQDN_CHAT,
|
||||||
|
# and EDGE_TUNNEL_FQDN (main project domain → staging).
|
||||||
|
_generate_caddyfile_subdomain() {
|
||||||
|
local caddyfile="$1"
|
||||||
|
cat > "$caddyfile" <<'CADDYFILEEOF'
|
||||||
|
# Caddyfile — edge proxy configuration (subdomain mode)
|
||||||
|
# Per-service subdomains; see docs/edge-routing-fallback.md
|
||||||
|
|
||||||
|
# Main project domain — staging / landing
|
||||||
|
{$EDGE_TUNNEL_FQDN} {
|
||||||
|
reverse_proxy staging:80
|
||||||
|
}
|
||||||
|
|
||||||
|
# Forgejo — root path, no subpath rewrite needed
|
||||||
|
{$EDGE_TUNNEL_FQDN_FORGE} {
|
||||||
|
reverse_proxy forgejo:3000
|
||||||
|
}
|
||||||
|
|
||||||
|
# Woodpecker CI — root path
|
||||||
|
{$EDGE_TUNNEL_FQDN_CI} {
|
||||||
|
reverse_proxy woodpecker:8000
|
||||||
|
}
|
||||||
|
|
||||||
|
# Chat — with forward_auth (#709, on its own host)
|
||||||
|
{$EDGE_TUNNEL_FQDN_CHAT} {
|
||||||
|
handle /login {
|
||||||
|
reverse_proxy chat:8080
|
||||||
|
}
|
||||||
|
handle /oauth/callback {
|
||||||
|
reverse_proxy chat:8080
|
||||||
|
}
|
||||||
|
handle /* {
|
||||||
|
forward_auth chat:8080 {
|
||||||
|
uri /auth/verify
|
||||||
|
copy_headers X-Forwarded-User
|
||||||
|
header_up X-Forward-Auth-Secret {$FORWARD_AUTH_SECRET}
|
||||||
|
}
|
||||||
|
reverse_proxy chat:8080
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CADDYFILEEOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate docker/index.html default page.
|
# Generate docker/index.html default page.
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,23 @@ check_pipeline_stall = false
|
||||||
# compact_pct = 60
|
# compact_pct = 60
|
||||||
# poll_interval = 60
|
# poll_interval = 60
|
||||||
|
|
||||||
|
# Edge routing mode (default: subpath)
|
||||||
|
#
|
||||||
|
# Controls how services are exposed through the edge proxy.
|
||||||
|
# subpath — all services under <project>.disinto.ai/{forge,ci,chat,staging}
|
||||||
|
# subdomain — per-service subdomains: forge.<project>, ci.<project>, chat.<project>
|
||||||
|
#
|
||||||
|
# Set to "subdomain" if subpath routing causes unfixable issues (redirect loops,
|
||||||
|
# OAuth callback mismatches, cookie collisions). See docs/edge-routing-fallback.md.
|
||||||
|
#
|
||||||
|
# Set in .env (not TOML) since it's consumed by docker-compose and shell scripts:
|
||||||
|
# EDGE_ROUTING_MODE=subdomain
|
||||||
|
#
|
||||||
|
# In subdomain mode, `disinto edge register` also writes:
|
||||||
|
# EDGE_TUNNEL_FQDN_FORGE=forge.<project>.disinto.ai
|
||||||
|
# EDGE_TUNNEL_FQDN_CI=ci.<project>.disinto.ai
|
||||||
|
# EDGE_TUNNEL_FQDN_CHAT=chat.<project>.disinto.ai
|
||||||
|
|
||||||
# [mirrors]
|
# [mirrors]
|
||||||
# github = "git@github.com:johba/disinto.git"
|
# github = "git@github.com:johba/disinto.git"
|
||||||
# codeberg = "git@codeberg.org:johba/disinto.git"
|
# codeberg = "git@codeberg.org:johba/disinto.git"
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,10 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO(#713): Subdomain fallback — if subpath routing (#704/#708) fails, this
|
|
||||||
# function would need to register additional routes for forge.<project>,
|
|
||||||
# ci.<project>, chat.<project> subdomains (or accept a --subdomain parameter).
|
|
||||||
# See docs/edge-routing-fallback.md for the full pivot plan.
|
|
||||||
|
|
||||||
# Register a new tunnel
|
# Register a new tunnel
|
||||||
# Usage: do_register <project> <pubkey>
|
# Usage: do_register <project> <pubkey>
|
||||||
|
# When EDGE_ROUTING_MODE=subdomain, also registers forge.<project>, ci.<project>,
|
||||||
|
# and chat.<project> subdomain routes (see docs/edge-routing-fallback.md).
|
||||||
do_register() {
|
do_register() {
|
||||||
local project="$1"
|
local project="$1"
|
||||||
local pubkey="$2"
|
local pubkey="$2"
|
||||||
|
|
@ -79,17 +76,32 @@ do_register() {
|
||||||
local port
|
local port
|
||||||
port=$(allocate_port "$project" "$full_pubkey" "${project}.${DOMAIN_SUFFIX}")
|
port=$(allocate_port "$project" "$full_pubkey" "${project}.${DOMAIN_SUFFIX}")
|
||||||
|
|
||||||
# Add Caddy route
|
# Add Caddy route for main project domain
|
||||||
add_route "$project" "$port"
|
add_route "$project" "$port"
|
||||||
|
|
||||||
|
# Subdomain mode: register additional routes for per-service subdomains
|
||||||
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
|
local subdomain
|
||||||
|
for subdomain in forge ci chat; do
|
||||||
|
add_route "${subdomain}.${project}" "$port"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Rebuild authorized_keys for tunnel user
|
# Rebuild authorized_keys for tunnel user
|
||||||
rebuild_authorized_keys
|
rebuild_authorized_keys
|
||||||
|
|
||||||
# Reload Caddy
|
# Reload Caddy
|
||||||
reload_caddy
|
reload_caddy
|
||||||
|
|
||||||
# Return JSON response
|
# Build JSON response
|
||||||
echo "{\"port\":${port},\"fqdn\":\"${project}.${DOMAIN_SUFFIX}\"}"
|
local response="{\"port\":${port},\"fqdn\":\"${project}.${DOMAIN_SUFFIX}\""
|
||||||
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
|
response="${response},\"routing_mode\":\"subdomain\""
|
||||||
|
response="${response},\"subdomains\":{\"forge\":\"forge.${project}.${DOMAIN_SUFFIX}\",\"ci\":\"ci.${project}.${DOMAIN_SUFFIX}\",\"chat\":\"chat.${project}.${DOMAIN_SUFFIX}\"}"
|
||||||
|
fi
|
||||||
|
response="${response}}"
|
||||||
|
echo "$response"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deregister a tunnel
|
# Deregister a tunnel
|
||||||
|
|
@ -109,9 +121,18 @@ do_deregister() {
|
||||||
# Remove from registry
|
# Remove from registry
|
||||||
free_port "$project" >/dev/null
|
free_port "$project" >/dev/null
|
||||||
|
|
||||||
# Remove Caddy route
|
# Remove Caddy route for main project domain
|
||||||
remove_route "$project"
|
remove_route "$project"
|
||||||
|
|
||||||
|
# Subdomain mode: also remove per-service subdomain routes
|
||||||
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
|
local subdomain
|
||||||
|
for subdomain in forge ci chat; do
|
||||||
|
remove_route "${subdomain}.${project}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Rebuild authorized_keys for tunnel user
|
# Rebuild authorized_keys for tunnel user
|
||||||
rebuild_authorized_keys
|
rebuild_authorized_keys
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue