Discourse Documentation Plugins & Custom Images

The charm is configured by default to deploy with discoursecharmers/discourse:v2.6.0 from Dockerhub, which is built from a Launchpad OCI Recipe. This is a docker image for Discourse with no extra plugins configured. A separate Launchpad OCI Recipe is used to build an image with the markdown and SAML plugins included, which can be used instead via discoursecharmers/discourse-markdown-saml:v2.6.0.

Building Other Configured Images

If you want to customise the image in any way, take a look at how image/Dockerfile is constructed to show how other plugins can be configured. Essentially that file builds a basic docker image for Discourse and then builds two versions based on that. We then use the IMAGE_TYPE variable to determine which actual image to generate. If you want to use an image with the Markdown and SAML plugins configured, you can simply run:

docker build --build-arg CONTAINER_APP_VERSION='v2.6.0' --build-arg IMAGE_TYPE=markdown-saml -t discourse-markdown-saml:v2.6.0 image/

This image type is also automatically pushed to dockerhub via a Launchpad OCI Reciple build, however, so you can use it without building yourself just by using discoursecharmers/discourse-markdown-saml:v2.6.0 as your discourse_image juju config option when deploying the charm.

Creating Custom Images

If you want to generate an image with other plugins configured, take a look at image/Dockerfile for examples. Let’s say you wanted to create an image with the “Markdown” plugin, but not “SAML”. You would modify image/Dockerfile as follows:

$ git status -v
On branch custom-plugins
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   image/Dockerfile

diff --git a/image/Dockerfile b/image/Dockerfile
index d314bb7..dcd710f 100644
--- a/image/Dockerfile
+++ b/image/Dockerfile
@@ -80,6 +80,14 @@ RUN echo "saml_full_screen_login = true" >> /srv/scripts/assets/discourse.conf.t
 
 RUN echo "markdown-saml image complete"
 
+FROM base-image AS markdown
+
+RUN cd ${CONTAINER_APP_ROOT}/app/plugins && git clone https://github.com/canonical-web-and-design/discourse-markdown-note.git
+RUN chown -R ${CONTAINER_APP_USERNAME}:${CONTAINER_APP_GROUP} ${CONTAINER_APP_ROOT}/app/plugins
+RUN cd ${CONTAINER_APP_ROOT}/app && su -s /bin/bash -c 'bin/bundle install' ${CONTAINER_APP_USERNAME}
+
+RUN echo "markdown image complete"
+
 # Build the final image based on the IMAGE_TYPE specified.
 FROM ${IMAGE_TYPE} AS final
 # Redeclare IMAGE_TYPE variable so it can be referenced inside this build

You could then run the following to generate this image:

docker build --build-arg CONTAINER_APP_VERSION='v2.6.0' --build-arg IMAGE_TYPE=markdown -t discourse-markdown:v2.6.0 image/