docker-flarum/README.md

254 lines
7.9 KiB
Markdown
Raw Permalink Normal View History

# mondedie/flarum
2016-07-17 05:35:13 -04:00
2019-12-28 13:26:58 -05:00
![logo](https://i.imgur.com/Bjrtbsc.png)
2016-07-17 05:35:13 -04:00
2020-05-06 08:22:35 -04:00
[![](https://github.com/mondediefr/docker-flarum/workflows/build/badge.svg)](https://github.com/mondediefr/docker-flarum/actions)
[![](https://img.shields.io/docker/pulls/mondedie/flarum)](https://hub.docker.com/r/mondedie/flarum)
[![](https://img.shields.io/docker/stars/mondedie/flarum)](https://hub.docker.com/r/mondedie/flarum)
2016-07-17 05:35:13 -04:00
2020-02-09 18:01:59 -05:00
### Tag available
2020-03-05 09:31:10 -05:00
- **latest** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/master/Dockerfile)
2020-05-11 18:51:32 -04:00
- **stable** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/master/Dockerfile)
2021-06-06 22:30:53 -04:00
- **1.0.2** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/1.0.2/Dockerfile)
2022-01-27 15:54:55 -05:00
- **1.2.0** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/1.2.0/Dockerfile)
2020-02-09 18:01:59 -05:00
2016-07-17 05:35:13 -04:00
### Features
2020-02-09 18:01:59 -05:00
- Multi-platform image: `linux/386`, `linux/amd64`, `linux/arm/v6`, `linux/arm/v7`, `linux/arm64`
2016-07-18 02:35:38 -04:00
- Lightweight & secure image
2022-06-05 17:01:08 -04:00
- Based on Alpine Linux 3.16
2021-03-16 13:20:57 -04:00
- **nginx** and **PHP 8.0**
2022-06-05 17:01:08 -04:00
- Latest [Flarum Framework](https://github.com/flarum/framework) (v1.3.0)
2016-07-17 05:35:13 -04:00
- MySQL/Mariadb driver
2016-07-18 02:35:38 -04:00
- OPCache extension configured
2016-07-17 05:35:13 -04:00
### Build-time variables
2022-06-05 17:01:08 -04:00
- **VERSION** = Version of [flarum/flarum](https://github.com/flarum/flarum) skeleton (default: *v1.3.0*)
2016-07-17 05:35:13 -04:00
### Ports
2016-09-25 05:27:13 -04:00
- Default: **8888** (configurable)
2016-09-25 05:27:13 -04:00
### Volume
- **/flarum/app/extensions** : Flarum extension directory
- **/flarum/app/public/assets** : Flarum assets directory
2021-05-30 19:36:46 -04:00
- **/flarum/app/storage/logs** : Flarum logs directory
- **/etc/nginx/flarum** : Nginx location directory
2016-09-25 05:27:13 -04:00
2016-07-17 05:35:13 -04:00
### Environment variables
2016-07-18 02:35:38 -04:00
| Variable | Description | Type | Default value |
| -------- | ----------- | ---- | ------------- |
2016-12-11 01:35:16 -05:00
| **UID** | Flarum user id | *optional* | 991
| **GID** | Flarum group id | *optional* | 991
2016-08-08 02:09:01 -04:00
| **DEBUG** | Flarum debug mode | *optional* | false
2016-07-18 02:35:38 -04:00
| **FORUM_URL** | Forum URL | **required** | none
| **DB_HOST** | MariaDB instance ip/hostname | *optional* | mariadb
| **DB_USER** | MariaDB database username | *optional* | flarum
| **DB_NAME** | MariaDB database name | *optional* | flarum
| **DB_PASS** | MariaDB database password | **required** | none
2016-10-28 13:29:42 -04:00
| **DB_PREF** | Flarum tables prefix | *optional* | none
2018-11-29 22:00:50 -05:00
| **DB_PORT** | MariaDB database port | *optional* | 3306
| **FLARUM_PORT** | Port to run Flarum on inside the container | *optional* | 8888
| **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M
| **PHP_MEMORY_LIMIT** | PHP memory limit | *optional* | 128M |
| **OPCACHE_MEMORY_LIMIT** | OPcache memory size in megabytes | *optional* | 128
2018-06-22 03:16:19 -04:00
| **LOG_TO_STDOUT** | Enable nginx and php error logs to stdout | *optional* | false
2019-11-28 08:56:30 -05:00
| **GITHUB_TOKEN_AUTH** | Github token to download private extensions | *optional* | false
| **PHP_EXTENSIONS** | Install additional php extensions | *optional* | none
2016-07-17 05:35:13 -04:00
### Required environment variable for first installation
2018-11-29 22:00:50 -05:00
| Variable | Description | Type | Default value |
| -------- | ----------- | ---- | ------------- |
| **FLARUM_ADMIN_USER** | Name of your user admin | **required** | none
| **FLARUM_ADMIN_PASS** | User admin password | **required** | none
| **FLARUM_ADMIN_MAIL** | User admin adress mail | **required** | none
| **FLARUM_TITLE** | Set a name of your flarum | *optional* | Docker-Flarum
2016-07-18 02:35:38 -04:00
## Installation
#### 1 - Pull flarum image
2016-07-18 01:34:39 -04:00
2018-01-30 15:35:42 -05:00
```bash
2016-10-23 17:18:57 -04:00
# Pull from hub.docker.com :
docker pull mondedie/flarum:latest
2016-10-23 17:18:57 -04:00
# or build it manually :
docker build -t mondedie/flarum:latest https://github.com/mondediefr/docker-flarum.git
2016-07-18 02:35:38 -04:00
```
2018-08-09 03:10:54 -04:00
#### 2 - Docker-compose.yml
2018-01-30 15:35:42 -05:00
```yml
version: "3"
2016-07-17 05:35:13 -04:00
2018-01-30 15:35:42 -05:00
services:
flarum:
2020-05-11 18:51:32 -04:00
image: mondedie/flarum:stable
2018-01-30 15:35:42 -05:00
container_name: flarum
2018-11-29 22:00:50 -05:00
env_file:
- /mnt/docker/flarum/flarum.env
2018-01-30 15:35:42 -05:00
volumes:
2018-11-29 22:47:57 -05:00
- /mnt/docker/flarum/assets:/flarum/app/public/assets
2018-01-30 15:35:42 -05:00
- /mnt/docker/flarum/extensions:/flarum/app/extensions
2021-05-30 19:36:46 -04:00
- /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
ports:
- 80:8888
2018-01-30 15:35:42 -05:00
depends_on:
- mariadb
2016-07-17 05:35:13 -04:00
2018-01-30 15:35:42 -05:00
mariadb:
2020-12-22 20:03:15 -05:00
image: mariadb:10.5
2018-01-30 15:35:42 -05:00
container_name: mariadb
environment:
2018-11-29 22:00:50 -05:00
- MYSQL_ROOT_PASSWORD=xxxxxxxxxx
2018-01-30 15:35:42 -05:00
- MYSQL_DATABASE=flarum
- MYSQL_USER=flarum
2018-11-29 22:00:50 -05:00
- MYSQL_PASSWORD=xxxxxxxxxx
2018-01-30 15:35:42 -05:00
volumes:
- /mnt/docker/mysql/db:/var/lib/mysql
```
2016-07-18 02:35:38 -04:00
2018-01-30 15:35:42 -05:00
#### 3 - Run it
2016-07-18 02:35:38 -04:00
2018-08-09 03:10:54 -04:00
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).
2016-07-17 05:35:13 -04:00
Create a environment file (see docker-compose: /mnt/docker/flarum/flarum.env [here](https://github.com/mondediefr/docker-flarum/tree/master#2---docker-composeyml))
2018-11-29 22:00:50 -05:00
```
# vi /mnt/docker/flarum/flarum.env
2018-11-29 22:00:50 -05:00
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 /!\
2018-11-29 22:00:50 -05:00
FLARUM_ADMIN_USER=admin
FLARUM_ADMIN_PASS=xxxxxxxxxx
FLARUM_ADMIN_MAIL=admin@domain.tld
FLARUM_TITLE=Test flarum
```
Run your docker-compose
```sh
2019-11-28 08:56:30 -05:00
docker-compose up -d mariadb
# Wait a moment for the creation of the database
docker-compose up -d flarum
2016-07-17 05:35:13 -04:00
```
* :warning: Your admin password must contain at least **8 characters** (FLARUM_ADMIN_PASS).
2018-01-30 15:35:42 -05:00
* 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.
2018-11-29 22:00:50 -05:00
![flarum-home](http://i.imgur.com/6kH9iTV.png)
### Install additional php extensions
```yml
version: "3"
services:
flarum:
image: mondedie/flarum:stable
container_name: flarum
environment:
2020-06-04 19:45:21 -04:00
- PHP_EXTENSIONS=gmp session brotli
volumes:
- /mnt/docker/flarum/assets:/flarum/app/public/assets
- /mnt/docker/flarum/extensions:/flarum/app/extensions
2021-05-30 19:36:46 -04:00
- /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
```
2021-05-30 17:30:07 -04:00
This example install php8-gmp php8-session and php8-brotli with apk
You can find a php extension here https://pkgs.alpinelinux.org/packages?name=php8-*&branch=v3.13&arch=x86_64
### Install custom extensions
**Flarum extensions list :** https://flagrow.io/extensions
#### Install an extension
```sh
docker exec -ti flarum extension require some/extension
```
#### Remove an extension
```sh
docker exec -ti flarum extension remove some/extension
```
#### List all extensions
```sh
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`
2021-05-30 17:42:54 -04:00
Create file in `/mnt/docker/flarum/nginx/custom-vhost-flarum.conf`
```nginx
# 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
2019-12-28 13:26:58 -05:00
### Guide for upgrade your flarum container
2019-12-11 20:56:45 -05:00
2019-12-28 13:26:58 -05:00
See the instructions [here](https://github.com/mondediefr/docker-flarum/blob/master/UPGRADE.md)
2020-03-05 09:31:10 -05:00
## License
Docker image [mondedie/flarum](https://hub.docker.com/r/mondedie/flarum) is released under [MIT License](https://github.com/mondediefr/docker-flarum/blob/master/LICENSE).