Caprover: Setting up discourse as a captain app

Created on 1 Nov 2018  路  4Comments  路  Source: caprover/caprover

As I have suggested here it would be great if a one-click app were available for the discourse user forum. In the absence of this, I am trying to set this up as a multi-click app within my captain family.

I followed the installation guide for discourse, on a standalone server, without captain, and it works as expected, but not of course within a captain context.

And since, as part of the setup process initiated by running discourse-setup, it installs the necessary components to provide a SSL-enabled server accessible at e.g. https://discourse.example.com, I'm guessing it's not going to play too well with captain if we try e.g. to run discourse-setup as part of the captain-definition?

question

All 4 comments

Although these "bootstrap" scripts make the setup easy on a barebone system, they completely defeat the purpose of Docker which is "making everything independent". I did a brief googling and found this one:
https://hub.docker.com/r/bitnami/discourse/

It's not their official image, but at least it's built the way docker images are supposed to be. Multiple separate containers for different services. I cannot provide any more detail on this as I have not installed Discourse at all, but their docs seem to be pretty good.

Any hints as to how to convert the suggested docker-compose installation into a captain context? I note that you are considering giving such an example... maybe this would be it? :-)

It's pretty much self explanatory.

version: '2'

services:
  postgresql:
    image: 'bitnami/postgresql:latest'
    volumes:
      - '/path/to/your/local/postgresql_data:/bitnami'
  redis:
    image: 'bitnami/redis:latest'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    volumes:
      - '/path/to/your/local/redis_data:/bitnami'
  discourse:
    image: 'bitnami/discourse:latest'
    ports:
      - '80:3000'
    volumes:
      - '/path/to/discourse-persistence:/bitnami'
    depends_on:
      - postgresql
      - redis
  sidekiq:
    image: 'bitnami/discourse:latest'
    depends_on:
      - discourse
    volumes:
      - '/path/to/sidekiq-persistence:/bitnami'
    command: 'nami start --foreground discourse-sidekiq'

postgresql and redis can be installed using one click apps. In the docker compose file above, redis has an environmental variable to allow empty password, but you can assign a password to your redis in the one click app wizard on Captain.

After postgres and redis are installed, you can create another app with persistence enabled, and add a volume, with container path of /bitnami. Next assign the following environmental variable to it:

- REDIS_PASSWORD <password you chose for redis>
- REDIS_HOST <srv-captain--redis-app-name>
- POSTGRESQL_ROOT_USER <root>
- POSTGRESQL_ROOT_PASSWORD <password you chose for postgres>
- POSTGRESQL_HOST <srv-captain--postgres-app-name>
- POSTGRESQL_HOST <srv-captain--postgres-app-name>

Then create a captain-definition like this:

 {
  "schemaVersion" :1 ,
  "dockerfileLines" :[
                        "FROM bitnami/discourse:latest"
                    ]
 }

convert it to tar file and upload it.

Do a similar process for sidekiq service, for captain-definition, go with this:

 {
  "schemaVersion" :1 ,
  "dockerfileLines" :[
                        "FROM bitnami/discourse:latest",
                        "CMD [ \"nami\",\"start\",\"--foreground\", \"discourse-sidekiq\" ]"
                    ]
 }

3 things to be careful:

  • when creating a service that needs env vars, first assign env vars, create volume and them upload captain-definition.
  • be careful about depends_on. i.e. ordering is important. In this case, redis and postgres do not depend on anything else, that's why we create them first.
  • In the docker-compose file, services are available via their name, i.e., host name for redis is redis. But when you use Captain, services are named like: srv-captain--redis. You need to find the right environmental variable from their docs, and assign the right host to it.

Finally, seems like discourse run on port 3000 and there is no environmental variable to control this, therefore you need to do this:
https://github.com/githubsaturn/captainduckduck/issues/130

Alternatively, you can follow exactly steps:
https://github.com/bitnami/bitnami-docker-discourse#mount-persistent-folders-manually

With some minor modifications:

  • Replace discourse-tier in all commands with captain-overlay-network, you don't need to create it, it's already created. i.e., skip step 1
  • In step 5, get rid of -p 80:3000 part of the command

Now just simply create a simple app (without persistence) on Captain, and forward all http request to discourse by editing the nginx config of the app you just created. Change this line:

set $upstream http://<%-s.localDomain%>;

to this:

set $upstream http://discourse;

If this gives you 502, try:

set $upstream http://discourse:3000;

their docs are inconsistent.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

icebob picture icebob  路  3Comments

Briston-KS picture Briston-KS  路  5Comments

gingerlime picture gingerlime  路  6Comments

Kimkykie picture Kimkykie  路  5Comments

polotto picture polotto  路  4Comments