fix: feat: configure Forgejo ROOT_URL for /forge/ subpath routing (#1080)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/nomad-validate Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/edge-subpath Pipeline was successful
ci/woodpecker/pr/nomad-validate Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/push/nomad-validate Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/edge-subpath Pipeline was successful
ci/woodpecker/pr/nomad-validate Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful
Move FORGEJO_ROOT_URL and WOODPECKER_HOST configuration to BEFORE generate_compose so the .env file is available for variable substitution. When EDGE_TUNNEL_FQDN is set with subpath routing mode, the .env file now gets FORGEJO_ROOT_URL=https://<fqdn>/forge/ written before docker-compose.yml is generated, ensuring the subpath is included in the generated compose file. This fixes the 404 on /forge/ by ensuring Forgejo's ROOT_URL includes the /forge/ prefix so its internal router recognizes the subpath. The Caddyfile already correctly does NOT strip the prefix - it passes the full /forge/... path to forgejo:3000.
This commit is contained in:
parent
abca547dcc
commit
02f8e13f33
1 changed files with 19 additions and 14 deletions
33
bin/disinto
33
bin/disinto
|
|
@ -1474,24 +1474,15 @@ p.write_text(text)
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate compose files (unless --bare)
|
|
||||||
if [ "$bare" = false ]; then
|
|
||||||
local forge_port
|
|
||||||
forge_port=$(printf '%s' "$forge_url" | sed -E 's|.*:([0-9]+)/?$|\1|')
|
|
||||||
forge_port="${forge_port:-3000}"
|
|
||||||
generate_compose "$forge_port" "$use_build"
|
|
||||||
generate_agent_docker
|
|
||||||
generate_caddyfile
|
|
||||||
generate_staging_index
|
|
||||||
# Create empty .env so docker compose can parse the agents service
|
|
||||||
# env_file reference before setup_forge generates the real tokens (#769)
|
|
||||||
touch "${FACTORY_ROOT}/.env"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure Forgejo and Woodpecker 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.
|
# In subdomain mode, uses per-service FQDNs at root path instead of subpath URLs.
|
||||||
|
# Must run BEFORE generate_compose so the .env file is available for variable substitution.
|
||||||
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
if [ -n "${EDGE_TUNNEL_FQDN:-}" ]; then
|
||||||
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
local routing_mode="${EDGE_ROUTING_MODE:-subpath}"
|
||||||
|
# Create .env file if it doesn't exist yet (needed before compose generation)
|
||||||
|
if [ "$bare" = false ] && [ ! -f "${FACTORY_ROOT}/.env" ]; then
|
||||||
|
touch "${FACTORY_ROOT}/.env"
|
||||||
|
fi
|
||||||
if [ "$routing_mode" = "subdomain" ]; then
|
if [ "$routing_mode" = "subdomain" ]; then
|
||||||
# Subdomain mode: Forgejo at forge.<project>.disinto.ai (root path)
|
# Subdomain mode: Forgejo at forge.<project>.disinto.ai (root path)
|
||||||
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
|
||||||
|
|
@ -1513,6 +1504,20 @@ p.write_text(text)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Generate compose files (unless --bare)
|
||||||
|
if [ "$bare" = false ]; then
|
||||||
|
local forge_port
|
||||||
|
forge_port=$(printf '%s' "$forge_url" | sed -E 's|.*:([0-9]+)/?$|\1|')
|
||||||
|
forge_port="${forge_port:-3000}"
|
||||||
|
generate_compose "$forge_port" "$use_build"
|
||||||
|
generate_agent_docker
|
||||||
|
generate_caddyfile
|
||||||
|
generate_staging_index
|
||||||
|
# Create empty .env so docker compose can parse the agents service
|
||||||
|
# env_file reference before setup_forge generates the real tokens (#769)
|
||||||
|
touch "${FACTORY_ROOT}/.env"
|
||||||
|
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
|
||||||
prompt_admin_password "${FACTORY_ROOT}/.env"
|
prompt_admin_password "${FACTORY_ROOT}/.env"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue