-
Notifications
You must be signed in to change notification settings - Fork 96
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
fix: main caddy service should send MFE requests to the mfe containers #23
Conversation
Thanks for the PR @jfavellar90! Since this change is only required in the nightly branch, could you please rebase your branch? Also, the "caddyfile" patch should probably look like this: (to be verified)
|
5009433
to
ad877e2
Compare
@regisb I already rebased the branch over the nightly branch. When trying the change you proposed to the "caddyfile" patch:
It fails when running On the other hand, port 8000 is not open in the MFE docker compose definition. Should we open it and serve the traffic through or use the 80 port (already open because of caddy service running in the MFE container I think)? |
This is very annoying. I created this The problem is that currently patches are rendered outside of the scope of the parent template. We could change the patch function to something like:
And then patches would not be rendered outside of the parent context. We would lose the error message in case the plugin patch is invalid. But, more importantly, we would also lose the ability to have patches that themselves include patches (so called "recursive patches"). I verified the latter problem with the following unit test:
Currently, this test passes. But with the proposed change, I get the following failure:
Another option is to create a global Another option is to pass the port as an environment variable, and then use it as I'll push this fix right now in the nightly and maple branches, so that you can update this PR.
You don't need to open the port in docker-compose. Port 8002 (and not 8000 as I wrote earlier) is open inside the docker-compose (and k8s) network. |
When nginx was removed in favour of caddy, we decided that plugin implementations of the "caddyfile" patch should make use of the "port" local variable. However, local variables are not available from inside plugin patches, which are rendered outside of the context of the parent templates. For a more extensive description of the problem, see: overhangio/tutor-mfe#23 (comment) We still want to make it easy for developers to decide what should the port be for caddy hosts. To do so, we make use of environment variables that are passed at runtime to the caddy container. Thus, a regular plugin patch should look like this: {{ PLUGIN_HOST }}{$default_site_port} { import proxy "myplugin:8000" }
Here is the commit in the Maple branch: overhangio/tutor@72baae0 |
Fixed by this commit. Sorry to close this @jfavellar90 but I needed this change for local testing. |
When nginx was removed in favour of caddy, we decided that plugin implementations of the "caddyfile" patch should make use of the "port" local variable. However, local variables are not available from inside plugin patches, which are rendered outside of the context of the parent templates. For a more extensive description of the problem, see: overhangio/tutor-mfe#23 (comment) We still want to make it easy for developers to decide what should the port be for caddy hosts. To do so, we make use of environment variables that are passed at runtime to the caddy container. Thus, a regular plugin patch should look like this: {{ PLUGIN_HOST }}{$default_site_port} { import proxy "myplugin:8000" }
When nginx was removed in favour of caddy, we decided that plugin implementations of the "caddyfile" patch should make use of the "port" local variable. However, local variables are not available from inside plugin patches, which are rendered outside of the context of the parent templates. For a more extensive description of the problem, see: overhangio/tutor-mfe#23 (comment) We still want to make it easy for developers to decide what should the port be for caddy hosts. To do so, we make use of environment variables that are passed at runtime to the caddy container. Thus, a regular plugin patch should look like this: {{ PLUGIN_HOST }}{$default_site_port} { import proxy "myplugin:8000" }
Since Nginx service and containers were removed in overhangio/tutor@e19f334, MFE traffic should be routed from caddy main service to caddy process running inside mfe containers.