Install Plugins in Discourse

So you want to install a plugin on your Discourse instance? Great, let’s get started!

:warning: The below advice to self install plugins only applies to self-hosted Discourse instances. If you are using a managed hosting service, the available plugins will be controlled by your hosting provider. For example, on our hosting these specific plugins are available by hosting tier.

In this tutorial, we’ll install Discourse Spoiler Alert plugin.

  • Copy the plugin’s GitHub or Bitbucket git clone url.

  • Access your container’s app.yml file (present in /var/discourse/containers/)

    cd /var/discourse
    nano containers/app.yml
    
  • Add the plugin’s repository URL to your container’s app.yml file:

    hooks:
      after_code:
        - exec:
            cd: $home/plugins
            cmd:
              - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
    

    (Add the plugin’s git clone url just below sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git)

  • Rebuild the container:

    cd /var/discourse
    ./launcher rebuild app
    

    That’s it, you’ve successfully installed the Discourse Spoiler Alert plugin on your Discourse instance!


Installing plugins hosted in a private repo

Use an OAuth token to install your plugin

This way you can install your plugin in the same space as any other and you don’t need to create an ssh key.

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
              - sudo -E -u discourse git clone https://<token>@github.com/owner/repo.git

:bookmark_tabs: An alternative method to install private plugins can be to use SSH keys. However, for most instances, OAuth tokens is the preferred method.

SSH Key Private Install Steps
run:
  - exec: echo "Beginning of custom commands"
  
  - exec: cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development
  - exec: echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /user/.ssh/config
  - file:
      path: /user/.ssh/id_rsa
      chmod: 600
      contents: |
        -----BEGIN RSA PRIVATE KEY-----
        MIIEogIBAAKCAQEArCQG213utzqE5YVjTVF5exGRCkE9OuM7LCp/FOuPdoHrFUXk
        y2MQcwf29J3A4i8zxpES9RdSEU6iIEsow98wIi0x1/Lnfx6jG5Y0/iQsG1NRlNCC
        aydGvGaC+PwwWiwYRc7PtBgV4KOAVXMZdMB5nFRaekQ1ksdH/360KCGgljPtzTNl
        09e97QBwHFIZ3ea5Eih/HireTrRSnvF+ywmwuxX4ubDr0ZeSceuF2S5WLXH2+TV0
           .... etc ....
        -----END RSA PRIVATE KEY-----
  - file:
      path: /user/.ssh/id_rsa.pub
      chmod: 600
      contents: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tj .... etc .... user@discourse
  - exec: cd $home/plugins && git clone git@github.com:SecretOrg/secret-plugin.git
  - exec: cd $home && sudo -E -u discourse bundle exec rake db:migrate
  - exec: cd $home && rm -fr tmp/cache
  - exec: cd $home &&  sudo -E -u discourse bundle exec rake assets:precompile
  - exec: rm /user/.ssh/id_rsa
  - exec: rm /user/.ssh/id_rsa.pub

  - exec: echo "End of custom commands"
  • Rebuild the container:
cd /var/discourse
./launcher rebuild app

Your private plugin should be installed on your Discourse instance.

113 Likes
Discourse Slackdoor Plugin
Site maintenance mode during rebuilds?
Discourse Version 1.2
How to create a new plugins?
Embed Etherpad Lite pads into Discourse
Data Explorer Plugin
Chatroom Integration Plugin (discourse-chat-integration)
How do I stop human spammers?
About the Plugin category
Can Plugins Be Added To Basic Docker Install
Solved Button Plugin
Formatting toolbar
Quick Messages Plugin
Checklist Plugin - Interactive Checkboxes made Simple
Discourse Zendesk Plugin
Does this software allow admin to put Adsense ads in?
Wild Apricot login plugin
LDAP Setup for Discourse
Graphviz Plugin
Admin Statistics Report
News Plugin :newspaper:
Discourse Push Notifications for Desktop
Update private plugin without rebuilding the application
OpenID Connect Authentication Plugin
ReplyGif: Adding reaction GIF easily
Watching Categories based on on group in discourse
How do i install plugins after doing a fork?
Daemonite Material Theme
User feedback plugin
Bump Reset plugin - Annotated to help new devs
Discourse Mark Plugin
Retort - a reaction-style plugin for Discourse
Generating lots of Invite Tokens
Babble - A Chat Plugin
Discourse Akismet Anti-Spam
Beginner’s Guide to Creating Discourse Plugins Part 6: Acceptance Tests
Favorites - select your favorite categories
Why do I need a block storage?
Projects management plugin
Adding location at sign up
Plugin for Preventing Malicious Linking
Custom Wizard Plugin :mage:
Login with Amazon Plugin
Knowledge Base Plugin
Discourse Fingerprint - Browser Fingerprinting Plugin
Plugin installation went wrong
Sidebar with categories
Topic Ratings Plugin
Merge Users Plugin
Steam Login / Authentication Plugin
Events Plugin :calendar:
Application Files after Digital Ocean Setup
How to enable [code] feature in the forum?
Unable to find /plugins dir
Pwned Passwords Validator
Launcher rebuild app does nothing
Private repo on Github
Mingle - An Introductions Plugin
Category Page Plugin
Checklist Plugin - Interactive Checkboxes made Simple
Stop Forum Spam Plugin (auto silence known spammers)
Any options for over-riding the username restrictions?
Collude - a collaborative text editor for Discourse
Features of the open source
Can't able to install plugins, whats the problem?
Google Perspective API Plugin
Can I access Discourse forum Database to use for PowerBI reporting?
Discourse Code Review
Who's Online Plugin (discourse-whos-online)
Discourse GitHub
Discourse Policy
Vk.com login (vkontakte)
Advanced Discourse Intercom
Custom Trust Level
Fatal: Not a git repository (or any parent up to mount point /discourse)
Fatal: Not a git repository (or any parent up to mount point /discourse)
I need someone who can install a voting plugin
Custom Wizard Plugin :mage:
Introducing Font Awesome 5 and SVG icons
Topic List Previews
Topic List Previews
Option in category setting not found
Knowledge Explorer Plugin
Discourse Spoiler Alert
Discourse Cookie Consent Banner
:spiral_calendar: Discourse Event
Follow Plugin 👨
Discourse-a2a-bbcode
Error using discourse-oauth2-basic plugin with NeonCRM
Discourse Assign
Question Answer Plugin
Discourse Math Editor - user friendly equations!
Discourse Subscriptions
Discourse Notifier
Discourse CommonMark text highlighting?
Mumble -- VOIP Plugin for Discourse
Advice on Installing Plugins
Cannot install plugin - nothing happens
Configure the Discourse RSS Polling Plugin
Topic Ratings Plugin
Discourse Shared Edits
Official Advertising / Ad Plugin for Discourse
Microsoft 365 OAuth2 Plugin
Installing discourse-math.git
Discourse Image Filter
Discourse Linkify Google Sheets
LDAP Auth Missing from Plugins
Discourse Solved (Accepted answer plugin)
LinkedIn OAuth2 Plugin
Discourse Canned Replies
Add Algolia search to your Discourse
Discourse BBCode
Discourse Voting missing table on postgresql
Discourse Math Plugin
Discourse Voting
OAuth2 Basic Support
Discourse Signatures
How to make a discourse forum look like forum.glamour.de
Discourse footnote
Cakeday! Celebrating birthdays and anniversaries
Discourse Sitemap
Discourse Spoiler Alert
Discourse-bcc: send individual PMs to users
Discourse Yearly Review Plugin
FontAwesome Pro icons
Discourse-teambuild: Run your own team building activity!
Discourse-tooltips - preview topic contents on hover
Restricted Replies - only allow certain groups to reply in a category
Add a button at the bottom of a topic, visible to a specific group: discourse-topic-group-button
Saved Searches Plugin
Add a button at the bottom of a topic, visible to everyone: discourse-custom-topic-button
Characters Required
Discourse BBCode color
Suppress updating of URL during topic navigation
User Notes Plugin
Discourse Post Sorting Customizer
Unikname Connect plugin
Discourse Video Upload Plugin with YouTube and Vimeo
Quoting not working
Discourse Calendar
[Solved] Admin-upgrade page not showing up
Synchronizer-base for any backup provider
"Your Docker installation is not using a supported storage driver."
Fixing problems with rebuild app
Auto Bookmarks plugin
Vk.com login (vkontakte)
Force specific users through moderation
Importing from phpBB3
Importing from phpBB3
Zoom Webinars Plugin
Discourse Affiliate Plugin
Voice recording plugin
How to hook up JWT Single Sign On to Discourse
Should all plugins be cloned as the `discourse` user?
Tickets Plugin :tickets:
Discourse Patreon Integration
OAuth2 integration with Drupal
Discourse Narrative Bot Beta Feedback
Discourse Translator
No option appears to choose better answer
How to block all crawlers but Google's
Discourse Avatar name_first_letter
Auto-suspend inactive users
How to ad banners?
Algolia plugin indexation
Telegram Notifications Plugin (discourse-telegram-notifications)
Configuring OneLogin's SAML for Discourse
Migrate from Digital Ocean to OVH?
Trying to install plugin (But not working)
How to break 99k char limit?
Availability of OpenID Connect in hosted plans
How to edit plugins code?
I want to install a plugin for development, what should I do?
Discourse Encrypt (for Private Messages)
Azure Blob Storage Plugin
Beginner's Guide to Creating Discourse Plugins - Part 1
./launcher rebuild app error './launcher: No such file or directory'
SSO for College Account
Installing Plugins with Git
Should all plugins be cloned as the `discourse` user?

Could you please give a full example with the suggested add on code? “Below” is very vague. Thanks

You can check the default app.yml for an example:

Thanks, but that also does not show an example of additional plugins.

This video does: Install Plugins in Discourse (Formatting Toolbar) - YouTube

So the code example should read (as it talks about the Spoiler Alert plugin:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
          - sudo -E -u discourse git clone https://github.com/discourse/discourse-spoiler-alert.git

Without that addition, the example is incomplete. Sorry, don’t want to be a pain, but hope this helps others. As this comment will be deleted after 6 months, an edit of the Original post is the only way.

Before the big cull of this topic there was a helpful post explaining what was actually required in the new line. I think maybe the text above was not needed.

I still find it confusing that here it’s recommended

          - sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git

but in the standalone.yml (and web_only.yml) templates it has:

      - git clone https://github.com/discourse/docker_manager.git

I guess the advantage of the sudo is that it saves some time chowning down the line?

I think that the templates and this howto should be the same.

1 Like

I do the second (non-how-to) version on the basis of a now-deleted post here, and it seems to work. I hope there is no advantage to the other way… but now feel I need to know :slight_smile:

Until @sam’s update on April 21 added the sudo the plain git clone was the recommendation. I imagine that few people have adopted this new method as the only place I have ever seen it is in this howto.

I haven’t adjusted any instance that I manage to do it this new way.

1 Like

Well, the sudo is required when you install with a limited user, here that user is called discourse. In general you should do that, so it is best practice.
But… this is the official documentation and it should be explained that then you need to call your limited user discourse.
That user is not created when you do the preferred install following the official documents at this moment by the way, but the original post here is only 6 years old.

1 Like