fix(forgejo): use forgejo.localhost ROOT_URL for cross-network resolution (#6)

Single hostname resolves both from browsers (RFC 6761) and inside docker (DNS alias). Fixes artifact upload ECONNREFUSED.
This commit is contained in:
forgejo_admin 2026-05-17 18:30:00 +04:00
parent c42e032e8d
commit 18dfc4e696
2 changed files with 21 additions and 3 deletions

View file

@ -3,11 +3,19 @@
# ---------- Forgejo ----------
FORGEJO_IMAGE=codeberg.org/forgejo/forgejo:10
FORGEJO_DOMAIN=localhost
FORGEJO_DOMAIN=forgejo.localhost
FORGEJO_SSH_DOMAIN=localhost
FORGEJO_HTTP_PORT=3000
FORGEJO_SSH_PORT=2222
FORGEJO_ROOT_URL=http://localhost:3000/
# Use forgejo.localhost (not bare localhost) so the same URL resolves both:
# - From browsers: *.localhost → 127.0.0.1 (RFC 6761; honored by Chrome,
# Firefox, Safari without /etc/hosts entries). Host port 3000 is mapped
# to the forgejo container.
# - From job containers: Docker DNS resolves forgejo.localhost via the
# network alias declared in docker-compose.yml (forgejo service).
# This avoids the ACTIONS_RUNTIME_URL mismatch that breaks artifact uploads
# when ROOT_URL is host-facing http://localhost:3000/.
FORGEJO_ROOT_URL=http://forgejo.localhost:3000/
# Admin user — created by bootstrap if absent
FORGEJO_ADMIN_USER=forgejo_admin

View file

@ -63,7 +63,17 @@ services:
interval: 10s
timeout: 5s
retries: 12
networks: [internal]
# Network alias so job containers can resolve the same hostname browsers
# use. *.localhost is special: per RFC 6761 every modern browser resolves
# it to 127.0.0.1 without an /etc/hosts entry, so users still reach
# Forgejo through the host port forward. Docker DNS resolves it inside
# the internal network to this container's IP. One hostname, two
# working resolution paths. Avoids the ACTIONS_RUNTIME_URL mismatch
# that breaks artifact uploads when ROOT_URL is host-facing localhost.
networks:
internal:
aliases:
- forgejo.localhost
runner:
image: ${RUNNER_IMAGE}