├── rootfs ├── etc │ ├── nginx │ │ ├── flarum │ │ │ └── .gitkeep │ │ └── nginx.conf │ ├── s6.d │ │ ├── nginx │ │ │ ├── crash │ │ │ ├── finish │ │ │ └── run │ │ ├── php8 │ │ │ ├── crash │ │ │ ├── finish │ │ │ └── run │ │ └── .s6-svscan │ │ │ ├── crash │ │ │ └── finish │ └── php8 │ │ ├── conf.d │ │ ├── apcu.ini │ │ ├── www.ini │ │ └── 00_opcache.ini │ │ └── php-fpm.d │ │ └── www.conf ├── flarum │ └── app │ │ ├── config.yml │ │ └── config.php.sample └── usr │ └── local │ └── bin │ ├── extension │ └── startup ├── .gitignore ├── .editorconfig ├── LICENSE ├── .github └── workflows │ ├── latest.yml │ └── stable.yml ├── UPGRADE.md ├── Dockerfile └── README.md /rootfs/etc/nginx/flarum/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/nginx/crash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exit 1 3 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/nginx/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exit 0 3 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/php8/crash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exit 1 3 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/php8/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exit 0 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docker-compose.yml 2 | docker 3 | flarum.env 4 | test.sh 5 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/.s6-svscan/crash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | echo "crash s6" 3 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/.s6-svscan/finish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | echo "stop s6" 3 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/nginx/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | /usr/sbin/nginx 3 | s6-svscanctl -qz /etc/s6.d 4 | -------------------------------------------------------------------------------- /rootfs/etc/s6.d/php8/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | /usr/sbin/php-fpm8 3 | s6-svscanctl -qz /etc/s6.d 4 | -------------------------------------------------------------------------------- /rootfs/etc/php8/conf.d/apcu.ini: -------------------------------------------------------------------------------- 1 | extension=apcu.so 2 | 3 | apc.enabled=1 4 | apc.shm_size=128M 5 | apc.ttl=7200 6 | -------------------------------------------------------------------------------- /rootfs/etc/php8/conf.d/www.ini: -------------------------------------------------------------------------------- 1 | post_max_size=100M 2 | upload_max_filesize=100M 3 | max_execution_time=10800 4 | max_input_time=3600 5 | expose_php=Off 6 | -------------------------------------------------------------------------------- /rootfs/etc/php8/conf.d/00_opcache.ini: -------------------------------------------------------------------------------- 1 | zend_extension=opcache.so 2 | 3 | opcache.enable=1 4 | opcache.enable_cli=1 5 | opcache.fast_shutdown=1 6 | opcache.memory_consumption= 7 | opcache.interned_strings_buffer=16 8 | opcache.max_accelerated_files=7963 9 | opcache.revalidate_freq=60 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /rootfs/flarum/app/config.yml: -------------------------------------------------------------------------------- 1 | debug: 2 | baseUrl: 3 | databaseConfiguration: 4 | driver: mysql 5 | host: 6 | database: 7 | username: 8 | password: 9 | prefix: 10 | port: 11 | adminUser: 12 | username: 13 | password: 14 | email: 15 | settings: 16 | forum_title: 17 | -------------------------------------------------------------------------------- /rootfs/etc/php8/php-fpm.d/www.conf: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | [global] 6 | daemonize = no 7 | error_log = /tmp/php_error.log 8 | 9 | [www] 10 | listen = /run/php/php8-fpm.sock 11 | pm = ondemand 12 | pm.max_children = 30 13 | pm.process_idle_timeout = 10s 14 | pm.max_requests = 500 15 | chdir = / 16 | php_admin_value[expose_php] = Off 17 | php_admin_value[post_max_size] = 18 | php_admin_value[upload_max_filesize] = 19 | php_admin_value[memory_limit] = 20 | -------------------------------------------------------------------------------- /rootfs/flarum/app/config.php.sample: -------------------------------------------------------------------------------- 1 | , 3 | 'offline' => false, 4 | 'database' => array ( 5 | 'driver' => 'mysql', 6 | 'host' => '', 7 | 'port' => '', 8 | 'database' => '', 9 | 'username' => '', 10 | 'password' => '', 11 | 'charset' => 'utf8mb4', 12 | 'collation' => 'utf8mb4_unicode_ci', 13 | 'prefix' => '', 14 | 'strict' => false, 15 | ), 16 | 'url' => '', 17 | 'paths' => array ( 18 | 'api' => 'api', 19 | 'admin' => 'admin', 20 | ), 21 | ); 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 mondedie/flarum 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/latest.yml: -------------------------------------------------------------------------------- 1 | name: latest 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | schedule: 8 | - cron: '0 19 1 * *' 9 | 10 | jobs: 11 | latest: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - 15 | name: Checkout 16 | uses: actions/checkout@v2 17 | - 18 | name: Set up QEMU 19 | uses: docker/setup-qemu-action@v1 20 | with: 21 | platforms: all 22 | - 23 | name: Set up Docker Buildx 24 | uses: docker/setup-buildx-action@v1 25 | with: 26 | version: latest 27 | - 28 | name: Dockerhub login 29 | env: 30 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 31 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 32 | run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin 33 | - 34 | name: Run Buildx 35 | run: | 36 | docker buildx build \ 37 | --pull \ 38 | --push \ 39 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 40 | --tag mondedie/flarum:latest . 41 | -------------------------------------------------------------------------------- /rootfs/etc/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes auto; 2 | pid /tmp/nginx.pid; 3 | daemon off; 4 | 5 | events { 6 | worker_connections 1024; 7 | use epoll; 8 | } 9 | 10 | http { 11 | include /etc/nginx/mime.types; 12 | default_type application/octet-stream; 13 | 14 | access_log off; 15 | error_log /tmp/ngx_error.log error; 16 | 17 | sendfile on; 18 | keepalive_timeout 15; 19 | keepalive_disable msie6; 20 | keepalive_requests 100; 21 | tcp_nopush on; 22 | tcp_nodelay on; 23 | server_tokens off; 24 | 25 | fastcgi_temp_path /tmp/fastcgi 1 2; 26 | client_body_temp_path /tmp/client_body 1 2; 27 | proxy_temp_path /tmp/proxy 1 2; 28 | uwsgi_temp_path /tmp/uwsgi 1 2; 29 | scgi_temp_path /tmp/scgi 1 2; 30 | 31 | server { 32 | listen ; 33 | charset utf-8; 34 | 35 | root /flarum/app/public; 36 | index index.php; 37 | 38 | client_max_body_size ; 39 | fastcgi_buffers 64 4K; 40 | 41 | include /flarum/app/.nginx.conf; 42 | 43 | # PHP Backend 44 | # -------------------------------------- 45 | location ~* \.php$ { 46 | try_files $uri =404; 47 | include fastcgi_params; 48 | fastcgi_split_path_info ^(.+\.php)(/.*)$; 49 | fastcgi_index index.php; 50 | fastcgi_pass unix:/run/php/php8-fpm.sock; 51 | fastcgi_intercept_errors on; 52 | fastcgi_request_buffering off; 53 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 54 | fastcgi_param PATH_INFO $fastcgi_path_info; 55 | fastcgi_param HTTP_PROXY ""; 56 | fastcgi_param REMOTE_ADDR $http_x_real_ip; 57 | } 58 | 59 | include /etc/nginx/flarum/custom-vhost-flarum[.]conf; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /rootfs/usr/local/bin/extension: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # COMPOSER WRAPUP SCRIPT 4 | # This script allow to add new extensions to flarum 5 | 6 | CSI="\033[" 7 | CEND="${CSI}0m" 8 | CRED="${CSI}1;31m" 9 | CGREEN="${CSI}1;32m" 10 | 11 | cd /flarum/app 12 | 13 | # Composer cache dir and packages list paths 14 | CACHE_DIR=/flarum/app/extensions/.cache 15 | LIST_FILE=/flarum/app/extensions/list 16 | 17 | # Cmd ARGS 18 | action="${1}" 19 | package="${2}" 20 | 21 | # Create custom extensions cache folder and list file 22 | su-exec "${UID}:${GID}" mkdir -p "${CACHE_DIR}" 23 | su-exec "${UID}:${GID}" touch "${LIST_FILE}" 24 | 25 | case "${action}" in 26 | # Install a flarum extension 27 | "require") 28 | COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer require "${package}" 29 | if [ $? -eq 0 ]; then 30 | echo "${package}" >> "${LIST_FILE}" 31 | echo -e "\n${CGREEN}${package} added to flarum.${CEND}" 32 | # Remove duplicate packages 33 | sort -u -o "${LIST_FILE}" "${LIST_FILE}" 34 | else 35 | echo -e "\n${CRED}/!\ An error has occurred...${CEND}" 36 | fi 37 | ;; 38 | # Remove a flarum extension 39 | "remove") 40 | COMPOSER_CACHE_DIR="$CACHE_DIR" su-exec "${UID}:${GID}" composer remove "${package}" 41 | if [ $? -eq 0 ]; then 42 | sed -i "\|${package}|d" "$LIST_FILE" 43 | echo -e "\n${CGREEN}${package} removed from flarum${CEND}" 44 | else 45 | echo -e "\n${CRED}/!\ An error has occurred...${CEND}" 46 | fi 47 | ;; 48 | "list") 49 | cat "${LIST_FILE}" 50 | ;; 51 | # Other composer action 52 | *) 53 | COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer "${@}" 54 | ;; 55 | esac 56 | 57 | su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear 58 | 59 | exit 0 60 | -------------------------------------------------------------------------------- /UPGRADE.md: -------------------------------------------------------------------------------- 1 | # Guide for upgrade your flarum container 2 | 3 | ### Upgrade to v1.3.0 from v1.2.0 4 | 5 | :warning: Backup your database, config.php, composer.lock and assets folder 6 | :warning: Disable all 3rd party extensions prior to upgrading in panel admin. 7 | 8 | 1 - Update your docker-compose file, see an example [here](https://github.com/mondediefr/docker-flarum/tree/master#2---docker-composeyml) 9 | 10 | ```yml 11 | version: "3" 12 | 13 | services: 14 | flarum: 15 | image: mondedie/flarum:1.3.0 16 | ... 17 | ``` 18 | 19 | 2 - Pull the last docker images 20 | 21 | ```sh 22 | docker pull mondedie/flarum:1.2.0 23 | docker-compose stop flarum 24 | docker-compose rm flarum 25 | docker-compose up -d flarum 26 | ``` 27 | 28 | 3 - Updating your database and removing old assets & extensions 29 | 30 | ```sh 31 | docker exec -ti flarum php /flarum/app/flarum migrate 32 | docker exec -ti flarum php /flarum/app/flarum cache:clear 33 | ``` 34 | 35 | After that your upgrade is finish. :tada: :tada: 36 | 37 | ### Upgrade to v1.2.0 from v1.0.2 38 | 39 | :warning: Backup your database, config.php, composer.lock and assets folder 40 | :warning: Disable all 3rd party extensions prior to upgrading in panel admin. 41 | 42 | 1 - Update your docker-compose file, see an example [here](https://github.com/mondediefr/docker-flarum/tree/master#2---docker-composeyml) 43 | 44 | ```yml 45 | version: "3" 46 | 47 | services: 48 | flarum: 49 | image: mondedie/flarum:1.2.0 50 | ... 51 | ``` 52 | 53 | 2 - Pull the last docker images 54 | 55 | ```sh 56 | docker pull mondedie/flarum:1.2.0 57 | docker-compose stop flarum 58 | docker-compose rm flarum 59 | docker-compose up -d flarum 60 | ``` 61 | 62 | 3 - Updating your database and removing old assets & extensions 63 | 64 | ```sh 65 | docker exec -ti flarum php /flarum/app/flarum migrate 66 | docker exec -ti flarum php /flarum/app/flarum cache:clear 67 | ``` 68 | 69 | After that your upgrade is finish. :tada: :tada: 70 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.16 2 | 3 | LABEL description="Simple forum software for building great communities" \ 4 | maintainer="Magicalex " 5 | 6 | ARG VERSION=v1.3.0 7 | 8 | ENV GID=991 \ 9 | UID=991 \ 10 | UPLOAD_MAX_SIZE=50M \ 11 | PHP_MEMORY_LIMIT=128M \ 12 | OPCACHE_MEMORY_LIMIT=128 \ 13 | DB_HOST=mariadb \ 14 | DB_USER=flarum \ 15 | DB_NAME=flarum \ 16 | DB_PORT=3306 \ 17 | FLARUM_TITLE=Docker-Flarum \ 18 | DEBUG=false \ 19 | LOG_TO_STDOUT=false \ 20 | GITHUB_TOKEN_AUTH=false \ 21 | FLARUM_PORT=8888 22 | 23 | RUN apk add --no-progress --no-cache \ 24 | curl \ 25 | git \ 26 | icu-data-full \ 27 | libcap \ 28 | nginx \ 29 | php8 \ 30 | php8-ctype \ 31 | php8-curl \ 32 | php8-dom \ 33 | php8-exif \ 34 | php8-fileinfo \ 35 | php8-fpm \ 36 | php8-gd \ 37 | php8-gmp \ 38 | php8-iconv \ 39 | php8-intl \ 40 | php8-mbstring \ 41 | php8-mysqlnd \ 42 | php8-opcache \ 43 | php8-pecl-apcu \ 44 | php8-openssl \ 45 | php8-pdo \ 46 | php8-pdo_mysql \ 47 | php8-phar \ 48 | php8-session \ 49 | php8-tokenizer \ 50 | php8-xmlwriter \ 51 | php8-zip \ 52 | php8-zlib \ 53 | su-exec \ 54 | s6 \ 55 | && cd /tmp \ 56 | && curl --progress-bar http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ 57 | && sed -i 's/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/' /etc/php8/php.ini \ 58 | && chmod +x /usr/local/bin/composer \ 59 | && mkdir -p /run/php /flarum/app \ 60 | && COMPOSER_CACHE_DIR="/tmp" composer create-project flarum/flarum:$VERSION /flarum/app \ 61 | && composer clear-cache \ 62 | && rm -rf /flarum/.composer /tmp/* \ 63 | && setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/nginx 64 | 65 | COPY rootfs / 66 | RUN chmod +x /usr/local/bin/* /etc/s6.d/*/run /etc/s6.d/.s6-svscan/* 67 | VOLUME /etc/nginx/flarum /flarum/app/extensions /flarum/app/public/assets /flarum/app/storage/logs 68 | CMD ["/usr/local/bin/startup"] 69 | -------------------------------------------------------------------------------- /.github/workflows/stable.yml: -------------------------------------------------------------------------------- 1 | name: stable 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | tag: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - 13 | name: Checkout 14 | uses: actions/checkout@v2 15 | - 16 | name: Set up QEMU 17 | uses: docker/setup-qemu-action@v1 18 | with: 19 | platforms: all 20 | - 21 | name: Set up Docker Buildx 22 | uses: docker/setup-buildx-action@v1 23 | with: 24 | version: latest 25 | - 26 | name: Dockerhub login 27 | env: 28 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 29 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 30 | run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin 31 | - 32 | name: Get tag name 33 | id: tag_name 34 | run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} 35 | - 36 | name: Run Buildx 37 | env: 38 | TAG: ${{ steps.tag_name.outputs.TAG }} 39 | run: | 40 | docker buildx build \ 41 | --pull \ 42 | --push \ 43 | --tag mondedie/flarum:"${TAG}" \ 44 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 45 | . 46 | stable: 47 | runs-on: ubuntu-latest 48 | steps: 49 | - 50 | name: Checkout 51 | uses: actions/checkout@v2 52 | - 53 | name: Set up QEMU 54 | uses: docker/setup-qemu-action@v1 55 | with: 56 | platforms: all 57 | - 58 | name: Set up Docker Buildx 59 | uses: docker/setup-buildx-action@v1 60 | with: 61 | version: latest 62 | - 63 | name: Dockerhub login 64 | env: 65 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 66 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 67 | run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin 68 | - 69 | name: Run Buildx 70 | run: | 71 | docker buildx build \ 72 | --pull \ 73 | --push \ 74 | --tag mondedie/flarum:stable \ 75 | --platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \ 76 | . 77 | -------------------------------------------------------------------------------- /rootfs/usr/local/bin/startup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Required env variables 4 | if [ -z "${DB_PASS}" ]; then 5 | echo "[ERROR] Mariadb database password must be set !" 6 | exit 1 7 | fi 8 | 9 | if [ -z "${FORUM_URL}" ]; then 10 | echo "[ERROR] Forum url must be set !" 11 | exit 1 12 | fi 13 | 14 | CACHE_DIR=/flarum/app/extensions/.cache 15 | LIST_FILE=/flarum/app/extensions/list 16 | 17 | # Set file config for nginx and php 18 | sed -i "s//${FLARUM_PORT}/g" /etc/nginx/nginx.conf 19 | sed -i "s//${UPLOAD_MAX_SIZE}/g" /etc/nginx/nginx.conf /etc/php8/php-fpm.d/www.conf 20 | sed -i "s//${PHP_MEMORY_LIMIT}/g" /etc/php8/php-fpm.d/www.conf 21 | sed -i "s//${OPCACHE_MEMORY_LIMIT}/g" /etc/php8/conf.d/00_opcache.ini 22 | 23 | # Set permissions for /flarum folder 24 | echo "[INFO] Setting folder permissions" 25 | for folder in /etc/s6.d /run/php /var/log /var/lib/nginx; do 26 | find ${folder} ! -user "${UID}" -exec chown -h "${UID}:${GID}" {} \+ 27 | find ${folder} ! -group "${GID}" -exec chown -h "${UID}:${GID}" {} \+ 28 | done 29 | 30 | find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \+ 31 | find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \+ 32 | 33 | # Set log output to STDOUT if wanted (LOG_TO_STDOUT=true) 34 | if [ "${LOG_TO_STDOUT}" = true ]; then 35 | echo "[INFO] Logging to stdout activated" 36 | chmod o+w /dev/stdout 37 | sed -i "s/.*error_log.*$/error_log \/dev\/stdout warn;/" /etc/nginx/nginx.conf 38 | sed -i "s/.*error_log.*$/error_log = \/dev\/stdout/" /etc/php8/php-fpm.d/www.conf 39 | fi 40 | 41 | # Install additional php extensions 42 | if [ -n "${PHP_EXTENSIONS}" ]; then 43 | for php_extension in ${PHP_EXTENSIONS}; do 44 | PACKAGES="php8-${php_extension} ${PACKAGES}" 45 | done 46 | echo "[INFO] Adding php extensions" 47 | apk add --no-progress --no-cache ${PACKAGES} 48 | fi 49 | 50 | cd /flarum/app 51 | 52 | # Add github token authentication (eg. for privates extensions) 53 | if [ "${GITHUB_TOKEN_AUTH}" != false ]; then 54 | echo "[INFO] Adding github token authentication" 55 | COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer config github-oauth.github.com "${GITHUB_TOKEN_AUTH}" 56 | fi 57 | 58 | # Custom repositories (eg. for privates extensions) 59 | if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then 60 | while read line; do 61 | repository="$(echo ${line} | cut -d '|' -f1)" 62 | json="$(echo ${line} | cut -d '|' -f2)" 63 | echo "[INFO] Adding ${repository} composer repository" 64 | COMPOSER_CACHE_DIR="${CACHE_DIR}" su-exec "${UID}:${GID}" composer config repositories."${repository}" --json "${json}" 65 | done < /flarum/app/extensions/composer.repositories.txt 66 | fi 67 | 68 | # if installation was performed before 69 | if [ -e '/flarum/app/public/assets/rev-manifest.json' ] || [ -e '/flarum/app/public/assets/._flarum-installed.lock' ] ; then 70 | echo "[INFO] Flarum already installed, init app..." 71 | 72 | sed -i -e "s||${DEBUG}|g" \ 73 | -e "s||${DB_HOST}|g" \ 74 | -e "s||${DB_NAME}|g" \ 75 | -e "s||${DB_USER}|g" \ 76 | -e "s||${DB_PASS}|g" \ 77 | -e "s||${DB_PREF}|g" \ 78 | -e "s||${DB_PORT}|g" \ 79 | -e "s||${FORUM_URL}|g" /flarum/app/config.php.sample 80 | 81 | cp -p /flarum/app/config.php.sample /flarum/app/config.php 82 | su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear 83 | 84 | # Download extra extensions installed with composer wrapup script 85 | if [ -s "${LIST_FILE}" ]; then 86 | echo "[INFO] Install extra bundled extensions" 87 | while read line; do 88 | extension="${extension}${line} " 89 | done < /flarum/app/extensions/list 90 | cmd="composer require ${extension}" 91 | eval "COMPOSER_CACHE_DIR=${CACHE_DIR} su-exec ${UID}:${GID} ${cmd}" 92 | echo "[INFO] Install extra bundled extensions: DONE" 93 | else 94 | echo "[INFO] No installed extensions" 95 | fi 96 | 97 | echo "[INFO] Flarum already installed, init app: DONE" 98 | else 99 | # if no installation was performed before 100 | echo "[INFO] First launch, installation..." 101 | 102 | if [ -z "${FLARUM_ADMIN_USER}" ] || [ -z "${FLARUM_ADMIN_PASS}" ] || [ -z "${FLARUM_ADMIN_MAIL}" ]; then 103 | echo "[ERROR] User admin info of flarum must be set !" 104 | exit 1 105 | fi 106 | 107 | sed -i -e "s||${DEBUG}|g" \ 108 | -e "s||${FORUM_URL}|g" \ 109 | -e "s||${DB_HOST}|g" \ 110 | -e "s||${DB_NAME}|g" \ 111 | -e "s||${DB_USER}|g" \ 112 | -e "s||${DB_PASS}|g" \ 113 | -e "s||${DB_PREF}|g" \ 114 | -e "s||${DB_PORT}|g" \ 115 | -e "s||${FLARUM_ADMIN_USER}|g" \ 116 | -e "s||${FLARUM_ADMIN_PASS}|g" \ 117 | -e "s||${FLARUM_ADMIN_MAIL}|g" \ 118 | -e "s||${FLARUM_TITLE}|g" /flarum/app/config.yml 119 | 120 | # Install flarum 121 | su-exec "${UID}:${GID}" php /flarum/app/flarum install --file=/flarum/app/config.yml \ 122 | && touch /flarum/app/public/assets/._flarum-installed.lock 123 | 124 | echo "[INFO] End of flarum installation" 125 | fi 126 | 127 | echo "[INFO] End of startup script. Forum is starting." 128 | exec su-exec "${UID}:${GID}" /bin/s6-svscan /etc/s6.d 129 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mondedie/flarum 2 | 3 | ![logo](https://i.imgur.com/Bjrtbsc.png) 4 | 5 | [![](https://github.com/mondediefr/docker-flarum/workflows/build/badge.svg)](https://github.com/mondediefr/docker-flarum/actions) 6 | [![](https://img.shields.io/docker/pulls/mondedie/flarum)](https://hub.docker.com/r/mondedie/flarum) 7 | [![](https://img.shields.io/docker/stars/mondedie/flarum)](https://hub.docker.com/r/mondedie/flarum) 8 | 9 | ### Tag available 10 | 11 | - **latest** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/master/Dockerfile) 12 | - **stable** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/master/Dockerfile) 13 | - **1.0.2** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/1.0.2/Dockerfile) 14 | - **1.2.0** [(Dockerfile)](https://github.com/mondediefr/docker-flarum/blob/1.2.0/Dockerfile) 15 | 16 | ### Features 17 | 18 | - Multi-platform image: `linux/386`, `linux/amd64`, `linux/arm/v6`, `linux/arm/v7`, `linux/arm64` 19 | - Lightweight & secure image 20 | - Based on Alpine Linux 3.16 21 | - **nginx** and **PHP 8.0** 22 | - Latest [Flarum Framework](https://github.com/flarum/framework) (v1.3.0) 23 | - MySQL/Mariadb driver 24 | - OPCache extension configured 25 | 26 | ### Build-time variables 27 | 28 | - **VERSION** = Version of [flarum/flarum](https://github.com/flarum/flarum) skeleton (default: *v1.3.0*) 29 | 30 | ### Ports 31 | 32 | - Default: **8888** (configurable) 33 | 34 | ### Volume 35 | 36 | - **/flarum/app/extensions** : Flarum extension directory 37 | - **/flarum/app/public/assets** : Flarum assets directory 38 | - **/flarum/app/storage/logs** : Flarum logs directory 39 | - **/etc/nginx/flarum** : Nginx location directory 40 | 41 | ### Environment variables 42 | 43 | | Variable | Description | Type | Default value | 44 | | -------- | ----------- | ---- | ------------- | 45 | | **UID** | Flarum user id | *optional* | 991 46 | | **GID** | Flarum group id | *optional* | 991 47 | | **DEBUG** | Flarum debug mode | *optional* | false 48 | | **FORUM_URL** | Forum URL | **required** | none 49 | | **DB_HOST** | MariaDB instance ip/hostname | *optional* | mariadb 50 | | **DB_USER** | MariaDB database username | *optional* | flarum 51 | | **DB_NAME** | MariaDB database name | *optional* | flarum 52 | | **DB_PASS** | MariaDB database password | **required** | none 53 | | **DB_PREF** | Flarum tables prefix | *optional* | none 54 | | **DB_PORT** | MariaDB database port | *optional* | 3306 55 | | **FLARUM_PORT** | Port to run Flarum on inside the container | *optional* | 8888 56 | | **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M 57 | | **PHP_MEMORY_LIMIT** | PHP memory limit | *optional* | 128M | 58 | | **OPCACHE_MEMORY_LIMIT** | OPcache memory size in megabytes | *optional* | 128 59 | | **LOG_TO_STDOUT** | Enable nginx and php error logs to stdout | *optional* | false 60 | | **GITHUB_TOKEN_AUTH** | Github token to download private extensions | *optional* | false 61 | | **PHP_EXTENSIONS** | Install additional php extensions | *optional* | none 62 | 63 | ### Required environment variable for first installation 64 | 65 | | Variable | Description | Type | Default value | 66 | | -------- | ----------- | ---- | ------------- | 67 | | **FLARUM_ADMIN_USER** | Name of your user admin | **required** | none 68 | | **FLARUM_ADMIN_PASS** | User admin password | **required** | none 69 | | **FLARUM_ADMIN_MAIL** | User admin adress mail | **required** | none 70 | | **FLARUM_TITLE** | Set a name of your flarum | *optional* | Docker-Flarum 71 | 72 | ## Installation 73 | 74 | #### 1 - Pull flarum image 75 | 76 | ```bash 77 | # Pull from hub.docker.com : 78 | docker pull mondedie/flarum:latest 79 | 80 | # or build it manually : 81 | docker build -t mondedie/flarum:latest https://github.com/mondediefr/docker-flarum.git 82 | ``` 83 | 84 | #### 2 - Docker-compose.yml 85 | 86 | ```yml 87 | version: "3" 88 | 89 | services: 90 | flarum: 91 | image: mondedie/flarum:stable 92 | container_name: flarum 93 | env_file: 94 | - /mnt/docker/flarum/flarum.env 95 | volumes: 96 | - /mnt/docker/flarum/assets:/flarum/app/public/assets 97 | - /mnt/docker/flarum/extensions:/flarum/app/extensions 98 | - /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs 99 | - /mnt/docker/flarum/nginx:/etc/nginx/flarum 100 | ports: 101 | - 80:8888 102 | depends_on: 103 | - mariadb 104 | 105 | mariadb: 106 | image: mariadb:10.5 107 | container_name: mariadb 108 | environment: 109 | - MYSQL_ROOT_PASSWORD=xxxxxxxxxx 110 | - MYSQL_DATABASE=flarum 111 | - MYSQL_USER=flarum 112 | - MYSQL_PASSWORD=xxxxxxxxxx 113 | volumes: 114 | - /mnt/docker/mysql/db:/var/lib/mysql 115 | ``` 116 | 117 | #### 3 - Run it 118 | 119 | 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). 120 | 121 | Create a environment file (see docker-compose: /mnt/docker/flarum/flarum.env [here](https://github.com/mondediefr/docker-flarum/tree/master#2---docker-composeyml)) 122 | 123 | ``` 124 | # vi /mnt/docker/flarum/flarum.env 125 | 126 | DEBUG=false 127 | FORUM_URL=http://domain.tld 128 | 129 | # Database configuration 130 | DB_HOST=mariadb 131 | DB_NAME=flarum 132 | DB_USER=flarum 133 | DB_PASS=xxxxxxxxxx 134 | DB_PREF=flarum_ 135 | DB_PORT=3306 136 | 137 | # User admin flarum (environment variable for first installation) 138 | # /!\ admin password must contain at least 8 characters /!\ 139 | FLARUM_ADMIN_USER=admin 140 | FLARUM_ADMIN_PASS=xxxxxxxxxx 141 | FLARUM_ADMIN_MAIL=admin@domain.tld 142 | FLARUM_TITLE=Test flarum 143 | ``` 144 | 145 | Run your docker-compose 146 | 147 | ```sh 148 | docker-compose up -d mariadb 149 | # Wait a moment for the creation of the database 150 | docker-compose up -d flarum 151 | ``` 152 | 153 | * :warning: Your admin password must contain at least **8 characters** (FLARUM_ADMIN_PASS). 154 | * 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. 155 | 156 | ![flarum-home](http://i.imgur.com/6kH9iTV.png) 157 | 158 | ### Install additional php extensions 159 | 160 | ```yml 161 | version: "3" 162 | 163 | services: 164 | flarum: 165 | image: mondedie/flarum:stable 166 | container_name: flarum 167 | environment: 168 | - PHP_EXTENSIONS=gmp session brotli 169 | volumes: 170 | - /mnt/docker/flarum/assets:/flarum/app/public/assets 171 | - /mnt/docker/flarum/extensions:/flarum/app/extensions 172 | - /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs 173 | - /mnt/docker/flarum/nginx:/etc/nginx/flarum 174 | ``` 175 | 176 | This example install php8-gmp php8-session and php8-brotli with apk 177 | You can find a php extension here https://pkgs.alpinelinux.org/packages?name=php8-*&branch=v3.13&arch=x86_64 178 | 179 | ### Install custom extensions 180 | 181 | **Flarum extensions list :** https://flagrow.io/extensions 182 | 183 | #### Install an extension 184 | 185 | ```sh 186 | docker exec -ti flarum extension require some/extension 187 | ``` 188 | 189 | #### Remove an extension 190 | 191 | ```sh 192 | docker exec -ti flarum extension remove some/extension 193 | ``` 194 | 195 | #### List all extensions 196 | 197 | ```sh 198 | docker exec -ti flarum extension list 199 | ``` 200 | 201 | ### Custom vhost flarum nginx 202 | 203 | File to change the vhost flarum `/etc/nginx/flarum/custom-vhost-flarum.conf` 204 | To use file custom-vhost-flarum.conf add volume `/etc/nginx/flarum` 205 | Create file in `/mnt/docker/flarum/nginx/custom-vhost-flarum.conf` 206 | 207 | ```nginx 208 | # Example of custom vhost flarum for nginx 209 | # fix nginx issue for fof/sitemap (https://github.com/FriendsOfFlarum/sitemap) 210 | 211 | location = /sitemap.xml { 212 | try_files $uri $uri/ /index.php?$query_string; 213 | } 214 | ``` 215 | 216 | ### Custom composer repositories 217 | 218 | To use the composer repository system, add your repo name and json representation in `/mnt/docker/flarum/extensions/composer.repositories.txt`: 219 | 220 | ``` 221 | my_private_repo|{"type":"path","url":"extensions/*/"} 222 | my_public_repo|{"type":"vcs","url":"https://github.com/my/repo"} 223 | ``` 224 | 225 | Example for a private repository in github 226 | 227 | Add this in `/mnt/docker/flarum/extensions/composer.repositories.txt` 228 | ``` 229 | username|{"type":"vcs","url":"https://github.com/username/my-private-repo"} 230 | ``` 231 | 232 | Create a token in github with full control of privates repository 233 | https://github.com/settings/tokens 234 | 235 | Add your github token in var environment 236 | ``` 237 | GITHUB_TOKEN_AUTH=XXXXXXXXXXXXXXX 238 | ``` 239 | 240 | Add your repo in the list file `/mnt/docker/flarum/extensions/list` 241 | ``` 242 | username/my-private-repo:0.1.0 243 | ``` 244 | 245 | https://getcomposer.org/doc/03-cli.md#modifying-repositories 246 | 247 | ### Guide for upgrade your flarum container 248 | 249 | See the instructions [here](https://github.com/mondediefr/docker-flarum/blob/master/UPGRADE.md) 250 | 251 | ## License 252 | 253 | 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). 254 | --------------------------------------------------------------------------------