openshift / console-plugin-template

Minimal template for writing OpenShift console plugins
Apache License 2.0
39 stars 51 forks source link

Local dev instructions aren't working (Option 1) #2

Closed mturley closed 2 years ago

mturley commented 2 years ago

Following the instructions in the README for local development under "Option 1: Local", it instructs me to run the plugin via yarn run start in one terminal and start the console in a container via yarn run start-console. In the console output, when I open the console in my browser I am seeing this error:

E0222 22:29:55.352596       1 handlers.go:165] GET request for "console-plugin-template" plugin failed: Get "http://host.docker.internal:9001/locales/en/plugin__console-plugin-template.json": dial tcp: lookup host.docker.internal on 192.168.5.3:53: no such host

It seems like the console wants to load from port 9001 in its docker environment rather than on my actual local machine where the plugin is running. (Note: I'm using Rancher Desktop to provide my dockerd runtime, maybe that's my issue? I'd expect it to work like any other Docker environment.)

We may want to add a third option in these instructions to describe running the console locally (not in a container) with ./bin/bridge, as described here: https://github.com/openshift/console/tree/master/frontend/packages/console-dynamic-plugin-sdk#plugin-development

Run Bridge locally and instruct it to proxy e.g. /api/plugins/console-demo-plugin requests directly to your local plugin asset server (web server hosting the plugin's generated assets):

./bin/bridge -plugins console-demo-plugin=http://localhost:9001/

Your plugin should start loading automatically upon Console application startup. Inspect the value of window.SERVER_FLAGS.consolePlugins to see the list of plugins which Console loads upon its startup.

This is useful in case you can't (or don't want to) set up a container runtime on your development machine, or if you need to develop changes to the console itself alongside changes to a plugin.

spadgett commented 2 years ago

Hey, @mturley. Are you still seeing this? What Docker version and what platform? If this is Linux, we might need to add this to the start-console.sh script:

--add-host=host.docker.internal:host-gateway

I can link out to the instructions to run bridge, but compiles are slow and it seems a lot more difficult.

mturley commented 2 years ago

Not seeing this anymore actually! Docker 20.10.16 (via Rancher Desktop) on Mac. Not sure what fixed it.

I can link out to the instructions to run bridge, but compiles are slow and it seems a lot more difficult.

No worries, I'm already running bridge myself on https://github.com/konveyor/crane-ui-plugin (with auth enabled too, which is a whole other can of worms). I was filing this as part of seeing if I could/should convert that repo over to use Docker. (I started that repo before Docker was introduced in this template)

I wonder how hard it would be to run in a container like this with auth enabled? We need a real oauth token on the user's session to test our plugin.

spadgett commented 2 years ago

I wonder how hard it would be to run in a container like this with auth enabled? We need a real oauth token on the user's session to test our plugin.

It's possible. You would have to edit the start-console.sh script to set the right env vars to use with auth. Basically you need to set the flags from here:

https://github.com/openshift/console/blob/master/examples/run-bridge.sh

The env var names are the same as the flag names, except prefixed with BRIDGE_, uppercase, and - replaced with _.

mturley commented 2 years ago

Thanks! I'll give that a try.