Docker subfolder install not working due to Ember-CLI proxy error?

(I’ve tagged this #unsupported-install but would appreciate guru input regardless :slight_smile:)

Guys, I’m trying to run a basic Discourse image in a simple-ish(?) multi docker container setup via Docker Compose.

Here’s the basics:

  • The forum is living in a subfolder, lets call it /board, so (https://blah.com/board)
  • nginx is passing calls to /board:443 to localhost:4000.
  • Discourse rails was running on port 4000 (because 3000 is being used by something else)
  • included in the Rails ENVs is a crucial setting which sets this up to work:
    DISCOURSE_RELATIVE_URL_ROOT: “/board”

Now I’ve updated the version of Discourse (pre Ember-CLI) and things are no longer working.

So, of course, I add a container for Ember-CLI which runs:

discourse-ember:
    command: bin/ember-cli --port 4000 --proxy "http://localhost:4200"

So Ember is now handling the calls coming in on 4000 in the first instance.

I move Discourse rails container to port 4200 and kick things off.

First the good news:

  • curling the dev site works!

Now the bad news:

  • Doesn’t work in browser, why?:

    because it’s apparently trying to reach Discourse but requesting:

/bootstrap.json

giving the error:

Discourse Ember CLI Proxy Error
Error: Could not get http://0.0.0.0:4200/bootstrap.json

FetchError: invalid json response body at http://0.0.0.0:4200/bootstrap.json?for_url=%2Fboard reason: Unexpected token N in JSON at position 0

instead of

/board/bootstrap.json (which returns data).

If instead I use this config:

  discourse-ember:
    command: bin/ember-cli --port 4000 --proxy "http://0.0.0.0:4200/forum"

I get a Rails error:

Routing Error
No route matches [GET] "/forum"

Yet not a few lines away, it provides me with:

bootstrap_path	GET	/bootstrap(.:format)	
bootstrap#index {:format=>/(json|html|\*\/\*)/}

Which is exactly the path I was trying to reach?

How do I make Ember smart enough to proxy to the subfolder when it’s trying to get the bootstrap info?, ie:

http://0.0.0.0:4200/forum/bootstrap.json

Remember, in this instance, Ember is running in its own container.

1 Like

How are you building the container? You’re launching that container from docker-compose?

There was . . . uh, some env setting . . . that could be used to try to keep ember-cli from working; did you remove that? (I think it’s ignored now anyway?)

Yes, these container definitions are in a docker-compose.

There are no environment settings in the ember-cli container currently.

You’re building the container with launcher with the stuff from Serve Discourse from a subfolder (path prefix) instead of a subdomain before you get docker-compose to launch it?

What’s the proxy? Maybe just launch discourse with launcher and use docker-args to set other stuff that is needed? For traefik, I do something like this:

        --docker-args "-l traefik.frontend.rule=Host:{{discourse_hostname}};PathPrefix:/{{discourse_subfolder}} \
        -l traefik.frontend.entryPoints=https \
        -l traefik.backend={{discourse_shortname}} \
        -l traefik.port=80 \
        {{ docker_extra_args | default('')}}"
1 Like

No, I’m just using a Discourse Docker Image (version 2.8.9).

(actually the image is hosted locally, but its pretty much:)

  discourse:
    command: bin/rails s -b 0.0.0.0 -p 4200
    image: discourse:v2.8.9
    environment:
      DISCOURSE_PORT: 4200
      DISCOURSE_RELATIVE_URL_ROOT: “/board”
     <SNIP>
    ports:
      - 4200:4200
  discourse-ember:
    command: bin/ember-cli --port 4000 --proxy "http://0.0.0.0:4200"
    image: discourse:v2.8.9
    ports:
      - 4000:4000

Hmm. In that case I can’t explain how it ever worked. I think you need to build an image with launcher that adds the stuff to support subfolder installs.

Solved.

My bad for not adding this to the Ember CLI container (it was already on the Rails container):

DISCOURSE_RELATIVE_URL_ROOT: "/board"

Ooops :sweat_smile:

FYI the key file in source is I believe this:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.