fix(): better management of persistent data 👌

pull/3/head
Hardware 2016-07-23 08:44:00 +02:00
parent eeaeb77510
commit 766c5a6d03
No known key found for this signature in database
GPG Key ID: EC6DF6F90263EDEA
5 changed files with 51 additions and 38 deletions

View File

@ -44,6 +44,6 @@ COPY startup /usr/local/bin/startup
RUN chmod +x /usr/local/bin/startup
VOLUME /flarum/www
VOLUME /flarum/app/assets
EXPOSE 8080
CMD ["/usr/bin/tini","--","startup"]

View File

@ -38,7 +38,7 @@ Flarum is the next-generation forum software that makes online discussion fun. I
### Volume
* /flarum/www : Flarum directory
* /flarum/app/assets : Flarum assets directory
## Installation
@ -91,7 +91,7 @@ flarum:
links:
- mariadb:mariadb
volumes:
- /mnt/docker/flarum:/flarum/www
- /mnt/docker/flarum:/flarum/app/assets
mariadb:
image: mariadb:10.1
@ -122,10 +122,6 @@ docker-compose up -d
* **Username** : *admin*
* **Password** : *password*
### Configuration file
The main configuration file is located here : **/mnt/docker/flarum/app/config.php**
### Screenshot
![flarum](https://i.imgur.com/teqg3od.pngP)

View File

@ -48,7 +48,7 @@ http {
server {
listen 8080;
root /flarum/www/app;
root /flarum/app;
index index.php;
access_log /var/log/nginx/access.log;

75
startup
View File

@ -21,12 +21,9 @@ if [ -z "$FORUM_URL" ]; then
exit 1
fi
# if no installation was performed before
if [ ! -e '/flarum/www/app/config.php' ]; then
cd /flarum/app/
# Flarum settings
# Installation settings
cat > config.yml <<EOF
databaseConfiguration:
driver: mysql
@ -38,14 +35,6 @@ databaseConfiguration:
baseUrl: ${FORUM_URL}
EOF
# Mail settings
sed -i -e "s|{{ MAIL_FROM }}|${MAIL_FROM}|g" \
-e "s|{{ MAIL_HOST }}|${MAIL_HOST}|g" \
-e "s|{{ MAIL_PORT }}|${MAIL_PORT}|g" \
-e "s|{{ MAIL_USER }}|${MAIL_USER}|g" \
-e "s|{{ MAIL_PASS }}|${MAIL_PASS}|g" \
-e "s|{{ MAIL_ENCR }}|${MAIL_ENCR}|g" config.sql
# Installer problem, wait fix in beta 6
# PHP Fatal error: Uncaught ReflectionException: Class flarum.config does not
# exist in /flarum/vendor/illuminate/container/Container.php
@ -54,29 +43,55 @@ sed -i -e 's|InfoCommand::class,||g' \
-e "s|\['config' => \$app->make('flarum.config')\]|['config' => \$app->isInstalled() ? \$app->make('flarum.config') : []]|g" vendor/flarum/core/src/Console/Server.php
# Set permissions
chown -R flarum:flarum /flarum/app
chown -R flarum:flarum .
# Install flarum (migrate database + assets)
su-exec flarum:flarum php flarum install --file config.yml
# if no installation was performed before
if [ ! -e 'assets/rev-manifest.json' ]; then
# Define flarum settings in database
mysql -h"${DB_HOST}" -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" < config.sql
# Mail settings
sed -i -e "s|{{ MAIL_FROM }}|${MAIL_FROM}|g" \
-e "s|{{ MAIL_HOST }}|${MAIL_HOST}|g" \
-e "s|{{ MAIL_PORT }}|${MAIL_PORT}|g" \
-e "s|{{ MAIL_USER }}|${MAIL_USER}|g" \
-e "s|{{ MAIL_PASS }}|${MAIL_PASS}|g" \
-e "s|{{ MAIL_ENCR }}|${MAIL_ENCR}|g" config.sql
# Install flarum
su-exec flarum:flarum php flarum install --file config.yml
# Define flarum settings in database
mysql -h"${DB_HOST}" -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" < config.sql
else
echo "[INFO] Flarum already installed, init app..."
# Disable already done steps during installation
# ----------------------------------------------
#
# See : flarum/core/src/Install/Console/DefaultsDataProvider.php
# flarum/core/src/Install/Console/InstallCommand.php
#
# runMigrations() = Database migration (Flarum\Database\Migrator)
# writeSettings() = Writing default flarum settings (Flarum\Settings\SettingsRepositoryInterface)
# seedGroups() = Create default groups
# seedPermissions() = Create default permissions
# createAdminUser() = Create default admin user
sed -i -e '/$this->runMigrations();/ s/^/#/' \
-e '/$this->writeSettings();/ s/^/#/' \
-e '/$this->seedGroups();/ s/^/#/' \
-e '/$this->seedPermissions();/ s/^/#/' \
-e '/$this->createAdminUser();/ s/^/#/' vendor/flarum/core/src/Install/Console/InstallCommand.php
# Init flarum (without steps above)
su-exec flarum:flarum php flarum install --file config.yml
echo "[INFO] Init done, launch flarum..."
fi
# Removing installation files
rm -f config.sql config.yml
# Moving sources to the final web directory
cd / && mv /flarum/app /flarum/www
else
echo "[INFO] Flarum already installed, launch app..."
# Removing the source directory
rm -rf /flarum/app
fi
# Set web directory permissions
chown -R flarum:flarum /flarum/www
# RUN !
exec supervisord -c /etc/supervisor/supervisord.conf

View File

@ -1,4 +1,6 @@
[supervisord]
logfile = /tmp/supervisord.log
pidfile = /tmp/supervisord.pid
nodaemon=true
[program:php-fpm]