Skip to content

fix: make server-side hostnames available through KeymanHosts #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025

Conversation

mcdurdin
Copy link
Member

For local environment, we need to use host.docker.internal as the hostname, with corresponding ports, in order for the sites in their containers be able to communicate with each other. This adds $SERVER_keyman_com variables etc to the KeymanHosts class, in preparation for fixing this across each of the sites.

This is also groundwork for allowing the various containers in the production and staging environments to communicate with each other directly, rather than going via cloudflare, which should improve performance and reduce traffic on the cluster. This change will be implemented in a follow-up PR.

For local environment, we need to use host.docker.internal as the
hostname, with corresponding ports, in order for the sites in
their containers be able to communicate with each other. This adds
`$SERVER_keyman_com` variables etc to the `KeymanHosts` class, in
preparation for fixing this across each of the sites.

This is also groundwork for allowing the various containers in the
production and staging environments to communicate with each other
directly, rather than going via cloudflare, which should improve
performance and reduce traffic on the cluster. This change will be
implemented in a follow-up PR.
@mcdurdin mcdurdin added this to the B18S1 milestone Feb 13, 2025
@mcdurdin mcdurdin added the fix label Feb 13, 2025
@mcdurdin mcdurdin requested a review from darcywong00 February 13, 2025 06:01
mcdurdin added a commit to keymanapp/keyman.com that referenced this pull request Feb 13, 2025
* Splits the server-side and client-side references to keyman sites so
  that docker-based PHP can reference host.docker.internal on
  development machines for cross-references.

* Removes all remaining usage of global `$KeymanHost` variable, instead
  using `KeymanHost::Instance()` for consistency.

* Removes some links to legacy sites such as sentry.keyman.com.

* TODO: update to `BOOTSTRAP_VERSION=v0.17` in build.sh before merge.

Relates-to: keymanapp/shared-sites#53
mcdurdin added a commit to keymanapp/api.keyman.com that referenced this pull request Feb 13, 2025
* Splits the server-side and client-side references to keyman sites so
  that docker-based PHP can reference host.docker.internal on
  development machines for cross-references.

* Removes some links to legacy sites such as sentry.keyman.com.

* TODO: update to `BOOTSTRAP_VERSION=v0.17` in build.sh before merge.

Relates-to: keymanapp/shared-sites#53
Relates-to: keymanapp/keyman.com#545
mcdurdin added a commit to keymanapp/keymanweb.com that referenced this pull request Feb 13, 2025
* Splits the server-side and client-side references to keyman sites so
  that docker-based PHP can reference host.docker.internal on
  development machines for cross-references.

* TODO: update to `BOOTSTRAP_VERSION=v0.17` in build.sh before merge.

Relates-to: keymanapp/shared-sites#53
Relates-to: keymanapp/keyman.com#545
Relates-to: keymanapp/api.keyman.com#272
mcdurdin added a commit to keymanapp/help.keyman.com that referenced this pull request Feb 13, 2025
* Splits the server-side and client-side references to keyman sites so
  that docker-based PHP can reference host.docker.internal on
  development machines for cross-references.

* TODO: update to `BOOTSTRAP_VERSION=v0.17` in build.sh before merge.

Relates-to: keymanapp/shared-sites#53
Relates-to: keymanapp/keyman.com#545
Relates-to: keymanapp/api.keyman.com#272
Relates-to: keymanapp/keymanweb.com#129
@mcdurdin mcdurdin marked this pull request as ready for review February 13, 2025 07:35
Comment on lines +127 to +131
$this->SERVER_s_keyman_com = "http://host.docker.internal:8054";
$this->SERVER_api_keyman_com = "http://host.docker.internal:8058";
$this->SERVER_help_keyman_com = "http://host.docker.internal:8055";
$this->SERVER_keyman_com = "http://host.docker.internal:8053";
$this->SERVER_keymanweb_com = "http://host.docker.internal:8057";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean these port values are never overridden by KEYMAN_COM_PROXY_PORT?

And do they need to be manually kept in sync with keyman-local-ports.inc.sh?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if ports change, we'd need to fix both places (plus a couple of other places where this has snuck in)

$this->SERVER_help_keyman_com = $this->help_keyman_com;
$this->SERVER_keyman_com = $this->keyman_com;
$this->SERVER_keymanweb_com = $this->keymanweb_com;
}
$this->fixupHosts();
}

private function fixupHosts() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these correspond to ll 34-35, could we rename to fixupSiteHostname()?

Just trying to follow all the uses of "hosts" in this file...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping to eliminate fixupHosts altogether in a future PR

Copy link
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@darcywong00 darcywong00 modified the milestones: B18S1, B18S2 Feb 15, 2025
@mcdurdin mcdurdin merged commit cc53630 into main Feb 16, 2025
2 checks passed
@mcdurdin mcdurdin deleted the fix/keyman-hosts-for-server branch February 16, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants