Move Bitnami Discourse Install to Discourse Docker Install

By Anil Gupta,  16 Jan, 18       0  Tech Tips

Move bitnami discourse install to official docker install by discourse team. Easy to upgrade and install plugins directly from admin page. Always run the most recent and updated copy of discourse. Better than Bitnami image.

We recently tried Bitnami Discourse image for google cloud to launch and run Discourse on Google compute engine but were not satisfied with their support and upgrade process.

Official Discourse Docker installsupports one-click online upgrade right from your admin, which is not supported by Bitnami image.

Hence, we decided to go with direct Discourse install ourselves. To our surprise, it was pretty as eating a baked cake in Starbucks!

Here are the steps if you would like to move your existing Discourse website with all its data to new server:

Move your Discourse Instance to a Different Server

To create a new Google Compute VM (1 vCPU, 3.75 GB memory). We will run Discourse Docker on this machine.

  1. First launch a Google compute engine instance with Ubuntu. At this time, we used this one:
    Google compute engine ubuntu
    Google compute engine ubuntu
  2. Click ‘Launch on compute Engine‘.
  3. On the next screen under ‘Firewalls‘, do not forget to check http and https traffic options.
  4. Wait for your instance to be set up by Google Launcher.
  5. Once done, click on the ‘ssh‘ button to launch the command prompt into your newly launched Ubuntu machine.
  6. On the command prompt, you can just follow this guide from Discourse directly line by line. Just a few commands and your discourse forum will be up and running.

    Follow the discourse install article:
  7. Wasn’t that easy? Any issues? Ask us in the comments and we will try to help you.

Moving your old server’s database and all files to new server

  1. Use the back up utility from the discourse admin on your current install (in our case, it is Bitnami’s discourse image) to create backup and download on your local machine.
    Go to your current Discourse Website->Admin->Backups->BackUp

    Create Discourse Back Up
    Create Discourse Back Up
  2. Then, upload this file to new install and use ‘restore’ button.
  3. The complete step by step process is given here by Discourse:

Error in restore

You might get this error while restoring from Bitnami install to most recent Discourse Docker install:

ERROR: unrecognized configuration parameter “idle_in_transaction_session_timeout”

This error is thrown as parameter idle_in_transaction_session_timeout was introduced in postgresql version 9.6..

The current bitnami image uses the postgresql verson 9.6.5 but the discourse docker is still on v 9.5.

The solution:

  1. Extract your current *.tar.gz back up file to .tar file using 7 Zip.
  2. Extract this .tar file to normal files.
  3. In the extracted files, you have one dump.sql.gz file.
  4. Extract it further to dump.sql using 7 Zip.

    At this time, you should be able to see these files:

    Discourse back-up un-zipped files
    Discourse back-up un-zipped files

  5. Open dump.sql file and find the line which has the variable ‘idle_in_transaction_session_timeout‘.
    Discourse postgresql error line
    Discourse postgresql error line

  6. Comment this line or delete it completely. Save and close the file.
  7. We now have to compress the file in reverse order of the way we extracted them.
  8. Make sure you keep the final *.tar.gz file name same as the original file that you downloaded from your current site’s discourse back up.

    Example, if the original back up file name was
    truvisa-2017-12-27-222220-v20170831180419.tar.gz, this should be same in the one you create it too.

  9. This file name has version number that is checked by discourse restore process. If you miss the version number in file name, restore process will fail again.
  10. Upload this file to your new server where you are trying to restore. Run and it should work fine now.

Changing app.yml file

app.yml file permissions by default:

discourse app.yml permissions
discourse app.yml permissions

To change ownership of app.yml to your own ID. This will help you modify file, if you are connecting to your compute engine VM using winscp

sudo chown USER_NAME:root -R /var/discourse/containers/app.yml

To change ownership back to root once you are done editing:

sudo chown root:root -R /var/discourse/containers/app.yml

To get into root mode in ssh shell anytime:

sudo -s

Then, you can run this command to re-build discourse:

cd /var/discourse

./launcher rebuild app

Re-build process takes a couple of minutes (around 3-4). Once, it is done, your discourse is up and running.

To check logs after re-build has completed:

./launcher logs app

Real Demo of Discourse Docker?

You can see this official Discourse Docker install running here:

Benefits of using official Discourse Docker Image vs Bitnami Discourse Image?

Your preference may be different but I found these immediate pros:

  1. Most updated and most recent Discourse version is installed by official one. At this time, Bitnami image usually lags behind by approximately 10 minor releases.
  2. I am not sure but many people have have argued that Bitnami image actually carries development version code of Discourse. If this is true, it straight-away makes it a slower proposition.
  3. I have explicitly observed that Bitnami’s version does NOT set ‘cache-control’ headers for static files. This is one of the biggest factor that will SLOW down your discourse install. My FIRST page load time was about 4.6 seconds with this image.

    Discourse static files Cache-control header
    Discourse static files Cache-control header

    After moving to Official Discourse Image, i have seen a direct reduction of about 2 seconds in FIRST page load time. That’s HUGE difference. This is due to that fact that I am using Google CDN with Load balancer and it automatically caches files with Cache-control header.

    With Bitnami image, nothing was getting cached. Neither at client browser nor at CDN level.

  4. You get Discourse one click upgrade option right in the Admin section for Discourse. With Bitnami, the upgrade process involves extensive back up, creating a NEW server and copying over all data to NEW server. That’s really a hell lot of work every-time you need to upgrade.