feat(): update to beta8

pull/34/head
Magicalex 2018-11-30 04:00:50 +01:00
parent c77de8962e
commit 6b023d1890
No known key found for this signature in database
GPG Key ID: A89B48B1788C3CB5
10 changed files with 145 additions and 125 deletions

19
.editorconfig Normal file
View File

@ -0,0 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
[*.{diff,md}]
trim_trailing_whitespace = false
[*.php]
indent_size = 4

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
docker-compose.yml
docker
flarum.env

View File

@ -1,9 +1,9 @@
FROM alpine:3.8
LABEL description "Next-generation forum software that makes online discussion fun" \
LABEL description "Simple forum software for building great communities" \
maintainer="Hardware <hardware@mondedie.fr>, Magicalex <magicalex@mondedie.fr>"
ARG VERSION=v0.1.0-beta.7
ARG VERSION=v0.1.0-beta.8
ENV GID=991 \
UID=991 \
@ -39,9 +39,8 @@ RUN echo "@community https://nl.alpinelinux.org/alpine/v3.8/community" >> /etc/a
php7-tokenizer@community \
php7-zip@community \
&& cd /tmp \
&& curl -s http://getcomposer.org/installer | php \
&& mv /tmp/composer.phar /usr/bin/composer \
&& chmod +x /usr/bin/composer \
&& curl -s http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& chmod +x /usr/local/bin/composer \
&& mkdir -p /flarum/app \
&& chown -R $UID:$GID /flarum \
&& COMPOSER_CACHE_DIR="/tmp" su-exec $UID:$GID composer create-project flarum/flarum /flarum/app $VERSION --stability=beta \
@ -50,6 +49,6 @@ RUN echo "@community https://nl.alpinelinux.org/alpine/v3.8/community" >> /etc/a
COPY rootfs /
RUN chmod +x /usr/local/bin/* /services/*/run /services/.s6-svscan/*
VOLUME /flarum/app/assets /flarum/app/extensions /etc/nginx/conf.d
EXPOSE 8888
VOLUME /flarum/app/extensions /etc/nginx/conf.d
EXPOSE 8080
CMD ["run.sh"]

View File

@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2016 Mondedie.fr
Copyright 2018 mondediefr/docker-flarum
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -9,22 +9,22 @@ Simple forum software for building great communities. http://flarum.org/
### Features
- Lightweight & secure image
- Based on Alpine Linux with **nginx** and **PHP 7**
- Latest [Flarum Core](https://github.com/flarum/core) (v0.1.0-beta.7.2)
- Based on Alpine Linux with **nginx** and **PHP 7.2**
- Latest [Flarum Core](https://github.com/flarum/core) (v0.1.0-beta.8)
- MySQL/Mariadb driver
- OPCache extension configured
### Build-time variables
- **VERSION** = Version of flarum (default: *v0.1.0-beta.7*)
- **VERSION** = Version of flarum (default: *v0.1.0-beta.8*)
### Ports
- **8888**
- **8080**
### Volume
- **/flarum/app/assets** : Flarum assets directory
- **/flarum/app/public/assets** : Flarum assets directory
- **/flarum/app/extensions** : Flarum extension directory
- **/etc/nginx/conf.d** : Nginx location directory
@ -41,18 +41,28 @@ Simple forum software for building great communities. http://flarum.org/
| **DB_NAME** | MariaDB database name | *optional* | flarum
| **DB_PASS** | MariaDB database password | **required** | none
| **DB_PREF** | Flarum tables prefix | *optional* | none
| **DB_PORT** | MariaDB database port | *optional* | 3306
| **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
| **LOG_TO_STDOUT** | Enable nginx and php error logs to stdout | *optional* | false
### Required environment variable for installation
| 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
## Installation
#### 1 - Pull flarum image
```bash
# Pull from hub.docker.com :
docker pull mondedie/docker-flarum:0.1.0-beta.7.2-stable
docker pull mondedie/docker-flarum:0.1.0-beta.8-stable
# or build it manually :
docker build -t mondedie/docker-flarum https://github.com/mondediefr/flarum.git#master
@ -65,11 +75,10 @@ version: "3"
services:
flarum:
image: mondedie/docker-flarum:0.1.0-beta.7.2-stable
image: mondedie/docker-flarum:0.1.0-beta.8-stable
container_name: flarum
environment:
- FORUM_URL=http://flarum.local
- DB_PASS=xxxxxx
env_file:
- /mnt/docker/flarum/flarum.env
volumes:
- /mnt/docker/flarum/assets:/flarum/app/assets
- /mnt/docker/flarum/extensions:/flarum/app/extensions
@ -78,13 +87,13 @@ services:
- mariadb
mariadb:
image: mariadb:10.1
image: mariadb:10.2
container_name: mariadb
environment:
- MYSQL_ROOT_PASSWORD=xxxxxx
- MYSQL_ROOT_PASSWORD=xxxxxxxxxx
- MYSQL_DATABASE=flarum
- MYSQL_USER=flarum
- MYSQL_PASSWORD=xxxxxx
- MYSQL_PASSWORD=xxxxxxxxxx
volumes:
- /mnt/docker/mysql/db:/var/lib/mysql
```
@ -93,23 +102,49 @@ services:
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 env file (see docker-compose -> /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
## admin password must contain at least 8 characters
FLARUM_ADMIN_USER=admin
FLARUM_ADMIN_PASS=xxxxxxxxxx
FLARUM_ADMIN_MAIL=admin@domain.tld
FLARUM_TITLE=Test flarum
```
run docker-flarum
```
docker-compose up -d
```
Fill out the installation form :
* Your admin password must contain at least **8 characters**.
* :warning: Your admin password must contain at least **8 characters**.
* You can't use MariaDB **10.2** or **10.3** for the moment. More information on this issue [here](https://github.com/flarum/core/issues/1211).
* 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-installation](http://i.imgur.com/e3Hscp4.png)
Click on **Install Flarum** and after few seconds the forum homepage should appear.
![flarum-home](http://i.imgur.com/6kH9iTV.png)
### Upgrade from v0.1.0-beta.6
### Upgrade to v0.1.0-beta.8 from v0.1.0-beta.7
:warning: Disable 3rd party extensions prior to upgrading.
```
docker pull mondedie/docker-flarum:0.1.0-beta.7.1-stable && docker-compose up -d
```
and...
### Upgrade to v0.1.0-beta.7 from v0.1.0-beta.6
:warning: Disable 3rd party extensions prior to upgrading.
@ -151,16 +186,6 @@ docker exec -ti flarum extension remove some/extension
docker exec -ti flarum extension list
```
### Custom error pages
To use custom error pages, add your .html files in `/mnt/docker/flarum/assets/errors` folder :
```bash
mkdir -p /mnt/docker/flarum/assets/errors
touch 403.html 404.html 500.html 503.html
chown -R 991:991 /mnt/docker/flarum
```
### Custom vhost flarum nginx
File to change the vhost flarum `/etc/nginx/conf.d/custom-vhost-flarum.conf`

View File

@ -53,49 +53,17 @@ http {
image/svg+xml;
server {
listen 8888;
root /flarum/app;
index index.php;
listen 8080;
charset utf-8;
root /flarum/app/public;
index index.php;
client_max_body_size <UPLOAD_MAX_SIZE>;
fastcgi_buffers 64 4K;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 /500.html;
error_page 503 /503.html;
location = /403.html { alias /flarum/app/vendor/flarum/core/error/403.html; }
location = /404.html { alias /flarum/app/vendor/flarum/core/error/404.html; }
location = /500.html { alias /flarum/app/vendor/flarum/core/error/500.html; }
location = /503.html { alias /flarum/app/vendor/flarum/core/error/503.html; }
location / { try_files $uri $uri/ /index.php?$query_string; }
location /api { try_files $uri $uri/ /api.php?$query_string; }
location /admin { try_files $uri $uri/ /admin.php?$query_string; }
# Access path list
# --------------------------------------
location ~ /\. {
deny all;
return 404;
}
location ~* ^/(Procfile|storage|Vagrantfile|config\.php|LICENSE|vendor|flarum|scripts) {
deny all;
return 404;
}
location ~* composer(.*?) {
deny all;
return 404;
}
location ~* (.*?)\.md {
deny all;
return 404;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Assets cache control
@ -133,7 +101,5 @@ http {
}
include /etc/nginx/conf.d/custom-vhost-flarum.conf;
}
}

View File

@ -1,7 +1,6 @@
<?php return array (
'debug' => <DEBUG>,
'database' =>
array (
'database' => array (
'driver' => 'mysql',
'host' => '<DB_HOST>',
'database' => '<DB_NAME>',
@ -13,8 +12,7 @@
'strict' => false,
),
'url' => '<FORUM_URL>',
'paths' =>
array (
'paths' => array (
'api' => 'api',
'admin' => 'admin',
),

View File

@ -0,0 +1,17 @@
debug: <DEBUG>
baseUrl: <FORUM_URL>
databaseConfiguration:
driver: mysql
host: <DB_HOST>
database: <DB_NAME>
username: <DB_USER>
password: <DB_PASS>
prefix: <DB_PREF>
port: <DB_PORT>
adminUser:
username: <FLARUM_ADMIN_USER>
password: <FLARUM_ADMIN_PASS>
password_confirmation: <FLARUM_ADMIN_PASS>
email: <FLARUM_ADMIN_MAIL>
settings:
forum_title: <FLARUM_TITLE>

View File

@ -9,16 +9,13 @@ CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m"
# Composer cache dir and packages list paths
CACHE_DIR=extensions/.cache
LIST_FILE=extensions/list
CACHE_DIR=/flarum/app/extensions/.cache
LIST_FILE=/flarum/app/extensions/list
# Cmd ARGS
action=$1
package=$2
# Move to flarum folder
cd /flarum/app
# Create custom extensions cache folder and list file
su-exec $UID:$GID mkdir -p "$CACHE_DIR"
su-exec $UID:$GID touch "$LIST_FILE"
@ -55,6 +52,6 @@ case "$action" in
;;
esac
su-exec $UID:$GID php flarum cache:clear
su-exec $UID:$GID php /flarum/app/flarum cache:clear
exit 0

View File

@ -1,15 +1,11 @@
#!/bin/sh
# Env variables
export DB_HOST
export DB_USER
export DB_NAME
export DEBUG
# Default values
DB_HOST=${DB_HOST:-mariadb}
DB_USER=${DB_USER:-flarum}
DB_NAME=${DB_NAME:-flarum}
DB_PORT=${DB_PORT:-3306}
FLARUM_TITLE=${FLARUM_TITLE:-Docker-Flarum}
DEBUG=${DEBUG:-false}
LOG_TO_STDOUT=${LOG_TO_STDOUT:-false}
@ -24,6 +20,7 @@ if [ -z "$FORUM_URL" ]; then
exit 1
fi
# Set file config for nginx and php
sed -i "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/php7/php-fpm.conf
sed -i "s/<PHP_MEMORY_LIMIT>/$PHP_MEMORY_LIMIT/g" /etc/php7/php-fpm.conf
sed -i "s/<OPCACHE_MEMORY_LIMIT>/$OPCACHE_MEMORY_LIMIT/g" /etc/php7/conf.d/00_opcache.ini
@ -31,8 +28,6 @@ sed -i "s/<OPCACHE_MEMORY_LIMIT>/$OPCACHE_MEMORY_LIMIT/g" /etc/php7/conf.d/00_op
# Set permissions
chown -R $UID:$GID /services /var/log /var/lib/nginx
cd /flarum/app
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
if [ "$LOG_TO_STDOUT" = true ]; then
echo "[INFO] Logging to stdout activated"
@ -41,21 +36,8 @@ if [ "$LOG_TO_STDOUT" = true ]; then
sed -i "s/.*error_log.*$/error_log = \/dev\/stdout/" /etc/php7/php-fpm.conf
fi
# Disable custom errors pages if debug mode is enabled
if [ "$DEBUG" = true ]; then
echo "[INFO] Debug mode enabled"
sed -i '/error_page/ s/^/#/' /etc/nginx/nginx.conf
fi
# Custom HTTP errors pages
if [ -d 'assets/errors' ]; then
echo "[INFO] Found custom errors pages"
rm -rf vendor/flarum/core/error/*
ln -s /flarum/app/assets/errors/* vendor/flarum/core/error
fi
# Custom repositories (eg. for privates extensions)
if [ -f 'extensions/composer.repositories.txt' ]; then
if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then
while read line; do
repository=$(echo $line | cut -d '|' -f1)
json=$(echo $line | cut -d '|' -f2)
@ -66,19 +48,15 @@ fi
# Custom vhost flarum nginx
if [ ! -e '/etc/nginx/conf.d/custom-vhost-flarum.conf' ]; then
echo '# Example:
# fix for flagrow/sitemap (https://github.com/flagrow/sitemap)
# location = /sitemap.xml {
# try_files $uri $uri/ /index.php?$query_string;
# }' > /etc/nginx/conf.d/custom-vhost-flarum.conf
fi
# if no installation was performed before
if [ -e 'assets/rev-manifest.json' ]; then
if [ -e '/flarum/app/public/assets/install.txt' ]; then
echo "[INFO] Flarum already installed, init app..."
sed -i -e "s|<DEBUG>|${DEBUG}|g" \
@ -87,13 +65,13 @@ if [ -e 'assets/rev-manifest.json' ]; then
-e "s|<DB_USER>|${DB_USER}|g" \
-e "s|<DB_PASS>|${DB_PASS}|g" \
-e "s|<DB_PREF>|${DB_PREF}|g" \
-e "s|<FORUM_URL>|${FORUM_URL}|g" config.php
-e "s|<FORUM_URL>|${FORUM_URL}|g" /flarum/app/config.php
su-exec $UID:$GID php flarum cache:clear
su-exec $UID:$GID php /flarum/app/flarum cache:clear
# Composer cache dir and packages list paths
CACHE_DIR=extensions/.cache
LIST_FILE=extensions/list
CACHE_DIR=/flarum/app/extensions/.cache
LIST_FILE=/flarum/app/extensions/list
# Download extra extensions installed with composer wrapup script
if [ -s "$LIST_FILE" ]; then
@ -108,15 +86,35 @@ if [ -e 'assets/rev-manifest.json' ]; then
fi
echo "[INFO] Init done, launch flarum..."
else
echo "[INFO] First launch, installation..."
rm -rf /flarum/app/config.php
echo "[INFO] First launch, you must install flarum by opening your browser and setting database parameters."
rm -rf config.php
if [ -z "$FLARUM_ADMIN_USER" ] || [ -z "$FLARUM_ADMIN_PASS" ] || [ -z "$FLARUM_ADMIN_MAIL" ]; then
echo "[ERROR] User admin info of flarum must be set !"
exit 1
fi
sed -i -e "s|<DEBUG>|${DEBUG}|g" \
-e "s|<FORUM_URL>|${FORUM_URL}|g" \
-e "s|<DB_HOST>|${DB_HOST}|g" \
-e "s|<DB_NAME>|${DB_NAME}|g" \
-e "s|<DB_USER>|${DB_USER}|g" \
-e "s|<DB_PASS>|${DB_PASS}|g" \
-e "s|<DB_PREF>|${DB_PREF}|g" \
-e "s|<DB_PORT>|${DB_PORT}|g" \
-e "s|<FLARUM_ADMIN_USER>|${FLARUM_ADMIN_USER}|g" \
-e "s|<FLARUM_ADMIN_PASS>|${FLARUM_ADMIN_PASS}|g" \
-e "s|<FLARUM_ADMIN_MAIL>|${FLARUM_ADMIN_MAIL}|g" \
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
php /flarum/app/flarum install --file=/flarum/app/config.yml
echo "[INFO] End of flarum installation"
echo "Done" > /flarum/app/public/assets/install.txt
fi
# Set permissions
# Set permissions for /flarum folder
find /flarum ! -user $UID -print0 | xargs -0 -r chown $UID:$GID
find /flarum ! -group $GID -print0 | xargs -0 -r chown $UID:$GID