Sign inSign up

forkdo/flarum

By forkdo

•Updated about 1 month ago

Docker image of Flarum

Image
0

2.1K

forkdo/flarum repository overview

⁠forkdo/flarum

logo

⁠Tag available
⁠Features
  • Multi-platform image: linux/arm64
  • Lightweight & secure image
  • Based on Alpine Linux 3.21
  • nginx and PHP 8.3
  • Latest Flarum Framework⁠ (v1.8.x)
  • MySQL/Mariadb driver
  • OPCache extension configured
⁠Build-time variables
⁠Ports
  • Default: 80 (configurable)
⁠Volume
  • /flarum/app/extensions : Flarum extension directory
  • /flarum/app/public/assets : Flarum assets directory
  • /flarum/app/storage/logs : Flarum logs directory
  • /etc/nginx/flarum : Nginx location directory
⁠Environment variables
VariableDescriptionTypeDefault value
UIDFlarum user idoptional991
GIDFlarum group idoptional991
DEBUGFlarum debug modeoptionalfalse
FORUM_URLForum URLrequirednone
DB_HOSTMariaDB instance ip/hostnameoptionalmariadb
DB_USERMariaDB database usernameoptionalflarum
DB_NAMEMariaDB database nameoptionalflarum
DB_PASSMariaDB database passwordrequirednone
DB_PREFFlarum tables prefixoptionalnone
DB_PORTMariaDB database portoptional3306
FLARUM_PORTPort to run Flarum on inside the containeroptional80
UPLOAD_MAX_SIZEThe maximum size of an uploaded fileoptional50M
PHP_MEMORY_LIMITPHP memory limitoptional128M
OPCACHE_MEMORY_LIMITOPcache memory size in megabytesoptional128
LOG_TO_STDOUTEnable nginx and php error logs to stdoutoptionalfalse
GITHUB_TOKEN_AUTHGithub token to download private extensionsoptionalfalse
PHP_EXTENSIONSInstall additional php extensionsoptionalnone
⁠Required environment variable for first installation
VariableDescriptionTypeDefault value
FLARUM_ADMIN_USERName of your user adminrequirednone
FLARUM_ADMIN_PASSUser admin passwordrequirednone
FLARUM_ADMIN_MAILUser admin adress mailrequirednone
FLARUM_TITLESet a name of your flarumoptionalDocker-Flarum

⁠Installation

⁠1 - Pull flarum image
# Pull from hub.docker.com :
docker pull forkdo/flarum:latest

# Pull from ghcr.io
docker pull ghcr.io/forkdo/flarum:latest

# or build it manually :
docker build -t forkdo/flarum:latest https://github.com/forkdo/docker-flarum.git
⁠2 - Docker-compose.yml
services:
  flarum:
    image: forkdo/flarum:latest
    container_name: flarum
    env_file:
      - /mnt/docker/flarum/flarum.env
    volumes:
      - /mnt/docker/flarum/assets:/flarum/app/public/assets
      - /mnt/docker/flarum/extensions:/flarum/app/extensions
      - /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
      - /mnt/docker/flarum/nginx:/etc/nginx/flarum
    ports:
      - 80:80
    depends_on:
      - mariadb

  mariadb:
    image: mariadb:10.5
    container_name: mariadb
    environment:
      - MYSQL_ROOT_PASSWORD=xxxxxxxxxx
      - MYSQL_DATABASE=flarum
      - MYSQL_USER=flarum
      - MYSQL_PASSWORD=xxxxxxxxxx
    volumes:
      - /mnt/docker/mysql/db:/var/lib/mysql
⁠3 - Run it

You need a reverse proxy to access flarum, this is not described here. You can use the solution of your choice (Traefik, Nginx, Apache, Haproxy, Caddy, H2O...etc).

Create a environment file (see docker-compose: /mnt/docker/flarum/flarum.env here⁠)

# vi /mnt/docker/flarum/flarum.env

DEBUG=false
FORUM_URL=http://domain.tld

# Database configuration
DB_HOST=mariadb
DB_NAME=flarum
DB_USER=flarum
DB_PASS=xxxxxxxxxx
DB_PREF=flarum_
DB_PORT=3306

# User admin flarum (environment variable for first installation)
# /!\ admin password must contain at least 8 characters /!\
FLARUM_ADMIN_USER=admin
FLARUM_ADMIN_PASS=xxxxxxxxxx
[email protected]
FLARUM_TITLE=Test flarum

Run your docker-compose

docker-compose up -d mariadb
# Wait a moment for the creation of the database
docker-compose up -d flarum
  • :warning: Your admin password must contain at least 8 characters (FLARUM_ADMIN_PASS).
  • If you get an error 500 with Something went wrong message, switch the DEBUG environment variable to true to see the actual error message in your browser.

flarum-home

⁠Install additional php extensions
services:
  flarum:
    image: forkdo/flarum:latest
    container_name: flarum
    environment:
      - PHP_EXTENSIONS=gmp session brotli
    volumes:
      - /mnt/docker/flarum/assets:/flarum/app/public/assets
      - /mnt/docker/flarum/extensions:/flarum/app/extensions
      - /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
      - /mnt/docker/flarum/nginx:/etc/nginx/flarum

This example install php83-gmp php83-session with apk
You can find a php extension here https://pkgs.alpinelinux.org/packages?name=php83-*&branch=v3.21&arch=x86_64⁠

⁠Install custom extensions

Flarum extensions list : https://flarum.org/extensions⁠

⁠Install an extension
docker exec -ti flarum extension require some/extension
⁠Remove an extension
docker exec -ti flarum extension remove some/extension
⁠List all extensions
docker exec -ti flarum extension list
⁠Custom vhost flarum nginx

File to change the vhost flarum /etc/nginx/flarum/custom-vhost-flarum.conf
To use file custom-vhost-flarum.conf add volume /etc/nginx/flarum Create file in /mnt/docker/flarum/nginx/custom-vhost-flarum.conf

# Example of custom vhost flarum for nginx
# fix nginx issue for fof/sitemap (https://github.com/FriendsOfFlarum/sitemap)

location = /sitemap.xml {
  try_files $uri $uri/ /index.php?$query_string;
}
⁠Custom composer repositories

To use the composer repository system, add your repo name and json representation in /mnt/docker/flarum/extensions/composer.repositories.txt:

my_private_repo|{"type":"path","url":"extensions/*/"}
my_public_repo|{"type":"vcs","url":"https://github.com/my/repo"}

Example for a private repository in github

Add this in /mnt/docker/flarum/extensions/composer.repositories.txt

username|{"type":"vcs","url":"https://github.com/username/my-private-repo"}

Create a token in github with full control of privates repository
https://github.com/settings/tokens⁠

Add your github token in var environment

GITHUB_TOKEN_AUTH=XXXXXXXXXXXXXXX

Add your repo in the list file /mnt/docker/flarum/extensions/list

username/my-private-repo:0.1.0

https://getcomposer.org/doc/03-cli.md#modifying-repositories⁠

⁠Guide for upgrade your flarum container

See the instructions here⁠

⁠License

Docker image forkdo/flarum⁠ is released under MIT License⁠.

Tag summary

Content type

Image

Digest

sha256:576e80915…

Size

56.9 MB

Last updated

about 1 month ago

docker pull forkdo/flarum