· Rajasekhar Gundala · Team Collaboration  · 8 min read

How to deploy Flarum 1.8.1 – Open Source Forum in docker swarm behind Traefik v2.0

Flarum is the next-generation forum software that makes online discussion fun. It’s simple, fast, and free.

Flarum is the next-generation forum software that makes online discussion fun. It’s simple, fast, and free.

In this post, I am going to deploy Flarum 0.1.0-beta.11 – An Open Source Forum Software in our Docker Swarm Cluster

Flarum is the next-generation forum software that makes online discussion fun. It’s simple, fast, and free.

Nowadays Internet Forums playing a key role in our day to activities. It’s a Place to connect, share common interests, Cater to the same audience, Get referrals and Attract targeted visitors.

Forum can be used as a Platform to answer queries

An Internet forum or message board is an online discussion site where people can hold conversations in the form of posted messages. They differ from chat rooms in that messages are often longer than one line of text, and are at least temporarily archived. Also, depending on the access level of a user or the forum setup, a posted message might need to be approved by a moderator before it becomes publicly visible.

Forums have a specific set of jargon associated with them; for example, a single conversation is called a thread or topic.

A discussion forum is hierarchical or tree-like in structure: a forum can contain a number of sub-forums, each of which may have several topics. Within a forum’s topic, each new discussion started is called a thread and can be replied to by as many people as so wish.

Depending on the forum’s settings, users can be anonymous or have to register with the forum and then subsequently log in to post messages. On most forums, users do not have to log in to read existing messages.

In this post, I am going to deploy Flarum 0.1.0-beta.11 – An Open Source Forum Software in our Docker Swarm Cluster.

Prerequisites

Please make sure you should fulfill the below requirements before proceeding to the actual deployment.

  1. Docker Swarm Cluster with GlusterFS as persistent tool.

  2. Traefik as reverse proxy to expose micro-services to external.

  3. Database stack to host application databases.

Introduction to Flarum 0.1.0-beta.11

Flarum is the next-generation forum software that makes online discussion fun. It’s simple, fast, and free.

Forums made simple with Flarum.

Flarum is a delightfully simple discussion platform for our websites. It’s fast and easy to use, with all the features you need to run a successful community. It is designed to be:

  • **Fast and simple-**No clutter, no bloat, no complex dependencies. Flarum is built with PHP so it’s quick and easy to deploy. The interface is powered by Mithril, a performant JavaScript framework with a tiny footprint.

  • **Beautiful and responsive-**This is forum software for humans. Flarum is carefully designed to be consistent and intuitive across platforms, out-of-the-box.

  • **Powerful and extensible-**Customize, extend, and integrate Flarum to suit your community. Flarum’s architecture is amazingly flexible, with a powerful Extension API.

Flarum GUI

Flarum is packed full of innovation, all wrapped up in a beautiful design. This isn’t just a nice skin. It’s forum software re-imagined.

Flarum 0.1.0-beta.11 Features

Most forums have the main hierarchy of categories, forums, and sub-forums – with tags tacked on the top. Flarum does away with all this complexity, and just has tags. They can have colors, positions, and hierarchies. A safe workspace with username restriction and admin transparency. Remove bad actors by adding moderators and provide admins with additional controls.

Organization, Simplified.

Flarum puts the tag list front-and-center when you’re starting a discussion, so you can focus on picking the right tags. Just choose all the relevant topics, and you’re done.

Fast to load and Performance You Can Trust

Flarum is built by the developers of esoTalk and FluxBB, two of the fastest and lightest forum platforms around, taking performance seriously.

Flarum Performance

Not everyone has access to a speedy Internet connection. Flarum’s assets are small, so users won’t turn away because a page is taking too long to load.

Flarum has 2-Pane View – Quickly work your way through unread discussions, without having to go back to the discussion list or open dozens of tabs. Bring your mouse to the left side of the screen and the discussion list will conveniently appear.

Infinite-Scrolling – Keep on scrolling, without having to wait for the next page of posts to load. Flarum lets you scrub anywhere in a discussion quickly and easily. It remembers your position if you come back after navigating away. That’s the beauty of free software, free refers not only to price but also the freedom to have complete control over it.

Floating-Composer – Read while you write. Flarum’s reply form slides up from the bottom of the page, so you can scroll up to read posts – and even visit other discussions – while you draft your reply.

Find below features of Flarum that meet current digital trends of the Mobile Era.

  1.  Elegant UI – Flarum looks and feels great out of the box. We can spend less time clicking and more time talking

  2.  Touch-Optimized – Flarum is fully responsive and the interface has been optimized for touch, with big buttons, smooth animations, and gestures aplenty.

  3.  Fast & Lightweight – Flarum is lightning fast. The front-end is powered by a lightweight JavaScript framework called Mithril. It’s slick, even on slower devices.

  4.  Powerful Permissions – Take control of your forum with fine-grained permissions. Assign permissions per-tag for extra flexibility.

  5.  Replies & Mentions – Mention users and reply to specific posts to make the discussion flow. Linear discussion just got an added dimension.

  6.  Tags – Organizing discussions has never been simpler. In Flarum, the flexibility of tags meets the structure of categories and sub-forums.

Find more about Flarum features using their official URL.

Persist Flarum Data

Containers are fast to deploy and make efficient use of system resources. Developers get application portability and programmable image management and the operations team gets standard run time units of deployment and management.

With all the known benefits of containers, there is one common misperception that the containers are ephemeral, which means if we restart the container or in case of any issues with it, we lose all the data for that particular container. They are only good for stateless micro-service applications and that it’s not possible to containerize stateful applications.

I am going to use GlusterFS to overcome the ephemeral behavior of Containers.

I already set up a replicated GlusterFS volume to have data replicated throughout the cluster if I would like to have some persistent data.

The below diagram explains how the replicated volume works.

Volume will be mounted on all the nodes, and when a file is written to the /mnt partition, data will be replicated to all the nodes in the Cluster

GlusterFS Replicated Volume

In case of any one of the nodes fails, the application automatically starts on other node without loosing any data and that’s the beauty of the replicated volume.

Persistent application state or data needs to survive application restarts and outages. We are storing the data or state in GlusterFS and had periodic backups performed on it.

We will use a backup of the volume to spin a new application container anywhere else in case of unexpected issues occur in the current environment.

I am going to persist /flarum/app/public/assets and /flarum/app/extension folders of Flarum for disorder recovery.

Create folders in /mnt directory to persistent Flarum assets and extensions.

cd /mnt
sudo mkdir -p fassets
sudo mkdir -p fextensions

Please watch the below video for Glusterfs Installation

https://www.youtube.com/embed/VU-cxFObPjI?feature=oembed

Prepare Flarum Environment

I am going to use docker compose to prepare environment file for deploying Rocket Chat application. The compose file is known as YAML ( YAML stands for Yet Another Markup Language) and has extension .yml or .yaml

I am going to create application folders in /opt location in Ubuntu to store configuration files, nothing but docker compose files (.yml or .yaml).

Now it’s time to create a folder, flarum inside /opt directory and also place configuration file, flarum.yml inside of it to deploy Rocket Chat using docker-compose.

Use the below commands to create the folder.

Go to /opt directory by typing cd /opt in Ubuntu console

Make a folder in /opt with sudo mkdir -p flarum

Let’s get into flarum folder by typing cd flarum

Now create docker compose file inside flarum folder using sudo touch flarum.yml

Open flarum.yml docker-compose file with nano editor using sudo nano flarum.yml and copy and paste the below code in it.

Flarum Docker Compose

Here is the docker compose file for Flarum. I am going to utilize the MariaDB stack as a back-end database for it that was deployed to our Docker Swarm Cluster previously.

version: "3.7"
 
services:
  flarum:
    image: mondedie/flarum:latest
    depends_on:
      - maindb
    ports:
      - '8888:80'
    environment:
      - FORUM_URL=https://flarum.example.com
      - DB_HOST=maindb
      - DB_NAME=mydiscuss
      - DB_USER=root
      - DB_PASS_FILE=/run/secrets/flarum_db_password
      - DB_PREF=disc_
      - DB_PORT:3306
      - FLARUM_ADMIN_USER=admin
      - FLARUM_ADMIN_PASS_FILE=/run/secrets/flarum_admin_password
      - FLARUM_ADMIN_MAIL=rajasekhar@rajasekhar.online
      - FLARUM_TITLE= Let's Discuss
    volumes:
      - /mnt/fassets:/flarum/app/public/assets
      - /mnt/fextensions:/flarum/app/extensions
    networks:
      - proxy
    deploy:
      placement:
        constraints: [node.role == worker]
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=proxy"
        - "traefik.http.routers.flarum.rule=Host(`flarum.example.com`)"
        - "traefik.http.routers.flarum.tls=true"
        - "traefik.http.routers.flarum.tls.certresolver=default"
        - "traefik.http.routers.flarum.entrypoints=websecure"
        - "traefik.http.services.flarum.loadbalancer.server.port=8888"
volumes:
  fassets:
    driver: "local"
  fextensions:
    driver: "local"
networks:
  proxy:
    external: true

I used Traefik stack that was deployed (proxy stack) earlier to Docker Swarm Cluster as a reverse proxy / load balancer.

Also proxy docker overlay network for the application to be accessible externally.

Deploy Flarum using Docker Compose

Now it’s time to deploy our docker compose file above, flarum.yml using the below command

docker stack deploy --compose-file flarum.yml flarum

In the above command, you have to replace flarum.yml with your docker-compose file name and flarum with whatever name you want to call this particular stack/application.

As mentioned earlier I named my docker-compose as flarum.yml and named my application stack as flarum

With docker compose in docker swarm what ever we are deploying is called as docker stack and it has multiple services in it as per the requirement.

Check flarum stack status using docker stack ps flarum

We can use docker service logs flarum_flarum to see flarum stack logs

Access Flarum

Now type http://flarum.example.com in the browser of your choice ( Be sure to replace example.com in the example above with your actual domain name).

Make sure that you have a DNS entry for your application (flarum.example.com) in your DNS Management Application.

Log into it by clicking on Log In button in the right top corner. Use admin user name and password mentioned in the docker-compose file.

Please find below images for your reference.

Flarum Stack PS Flarum Service Logs Flarum Welcome Screen Flarum Login Screen Flarum Home Screen Flarum Admin GUI Flarum User Settings Flarum Tags Flarum Extensions Flarum Start a Discussion Flarum Discussion Settings Flarum Infinite Scrolling

We have deployed Flarum to our Docker Swarm successfully.

Stay tuned for other deployments in the next post… 🙄

Let me know your feedback or thoughts by commenting on it below.

Back to Blog