Take the foundation's ports as genesis inputs, check them free, and hand them to the controller as the node's settings (hq ADR 0100)
This commit is contained in:
@@ -42,8 +42,9 @@ const (
|
||||
// giteaDBRole/giteaDBName is gitea's own database in the foundation store.
|
||||
giteaDBRole = "mesh_gitea"
|
||||
giteaDBName = "mesh_gitea"
|
||||
// giteaPort is where the raised server answers on the machine.
|
||||
giteaPort = 3000
|
||||
// defaultGiteaPort is where the raised server answers on the machine unless the node gave the
|
||||
// package registry another port (novox/hq ADR 0100).
|
||||
defaultGiteaPort = 3000
|
||||
)
|
||||
|
||||
// RaisePackageRegistry puts a working npm registry in front of the base build. It is idempotent:
|
||||
@@ -60,17 +61,18 @@ func RaisePackageRegistry(ctx context.Context, o Options, d Deps, control contro
|
||||
}
|
||||
|
||||
say(" seeding gitea's database in the foundation store")
|
||||
ports := o.Ports.orDefaults()
|
||||
if err := seedGiteaDatabase(ctx, run, o.Timeout, dbPassword, say); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
say(" raising the gitea server on that database")
|
||||
if err := raiseGiteaServer(ctx, run, o.Timeout, dbPassword, say); err != nil {
|
||||
if err := raiseGiteaServer(ctx, run, o.Timeout, dbPassword, ports, say); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
say(" waiting for gitea to answer")
|
||||
base := fmt.Sprintf("http://127.0.0.1:%d", giteaPort)
|
||||
base := fmt.Sprintf("http://127.0.0.1:%d", ports.Packages)
|
||||
if err := waitForGitea(ctx, d, o, base, say); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -150,7 +152,7 @@ func seedGiteaDatabase(ctx context.Context, run Runner, timeout time.Duration, p
|
||||
// store's network namespace so `127.0.0.1:5432` reaches postgres, and publishes its own port on the
|
||||
// machine so the builder and this installer can reach it. Started if absent, left alone if present.
|
||||
func raiseGiteaServer(ctx context.Context, run Runner, timeout time.Duration, dbPassword string,
|
||||
say func(string)) error {
|
||||
ports FoundationPorts, say func(string)) error {
|
||||
asking, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
|
||||
@@ -164,7 +166,7 @@ func raiseGiteaServer(ctx context.Context, run Runner, timeout time.Duration, db
|
||||
env := []string{
|
||||
"-e", "GITEA__database__DB_TYPE=postgres",
|
||||
// The store is reached on the shared network namespace's loopback.
|
||||
"-e", "GITEA__database__HOST=127.0.0.1:5432",
|
||||
"-e", fmt.Sprintf("GITEA__database__HOST=127.0.0.1:%d", ports.Store),
|
||||
"-e", "GITEA__database__NAME=" + giteaDBName,
|
||||
"-e", "GITEA__database__USER=" + giteaDBRole,
|
||||
"-e", "GITEA__database__PASSWD=" + dbPassword,
|
||||
@@ -174,9 +176,14 @@ func raiseGiteaServer(ctx context.Context, run Runner, timeout time.Duration, db
|
||||
// package metadata hands npm a tarball URL built from ROOT_URL, and a client only sends its
|
||||
// stored credential to the host it was stored for. A default ROOT_URL of localhost is a
|
||||
// different host than the binding's 127.0.0.1, so the credential would not be sent.
|
||||
"-e", fmt.Sprintf("GITEA__server__ROOT_URL=http://127.0.0.1:%d/", giteaPort),
|
||||
"-e", fmt.Sprintf("GITEA__server__ROOT_URL=http://127.0.0.1:%d/", ports.Packages),
|
||||
"-e", "USER_UID=1000", "-e", "USER_GID=1000",
|
||||
}
|
||||
if ports.Packages != defaultGiteaPort {
|
||||
// On the machine's network the server binds its own port, so a port given for it is
|
||||
// the one it is told to listen on.
|
||||
env = append(env, "-e", fmt.Sprintf("GITEA__server__HTTP_PORT=%d", ports.Packages))
|
||||
}
|
||||
args := append([]string{
|
||||
"run", "-d", "--name", giteaBootstrap,
|
||||
// Host network, like the control plane: it reaches the foundation store on the machine's
|
||||
|
||||
Reference in New Issue
Block a user