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 RUN chmod +x /usr/local/bin/startup
VOLUME /flarum/www VOLUME /flarum/app/assets
EXPOSE 8080 EXPOSE 8080
CMD ["/usr/bin/tini","--","startup"] 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 ### Volume
* /flarum/www : Flarum directory * /flarum/app/assets : Flarum assets directory
## Installation ## Installation
@ -91,7 +91,7 @@ flarum:
links: links:
- mariadb:mariadb - mariadb:mariadb
volumes: volumes:
- /mnt/docker/flarum:/flarum/www - /mnt/docker/flarum:/flarum/app/assets
mariadb: mariadb:
image: mariadb:10.1 image: mariadb:10.1
@ -122,10 +122,6 @@ docker-compose up -d
* **Username** : *admin* * **Username** : *admin*
* **Password** : *password* * **Password** : *password*
### Configuration file
The main configuration file is located here : **/mnt/docker/flarum/app/config.php**
### Screenshot ### Screenshot
![flarum](https://i.imgur.com/teqg3od.pngP) ![flarum](https://i.imgur.com/teqg3od.pngP)

View File

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

69
startup
View File

@ -21,12 +21,9 @@ if [ -z "$FORUM_URL" ]; then
exit 1 exit 1
fi fi
# if no installation was performed before
if [ ! -e '/flarum/www/app/config.php' ]; then
cd /flarum/app/ cd /flarum/app/
# Flarum settings # Installation settings
cat > config.yml <<EOF cat > config.yml <<EOF
databaseConfiguration: databaseConfiguration:
driver: mysql driver: mysql
@ -38,14 +35,6 @@ databaseConfiguration:
baseUrl: ${FORUM_URL} baseUrl: ${FORUM_URL}
EOF 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 # Installer problem, wait fix in beta 6
# PHP Fatal error: Uncaught ReflectionException: Class flarum.config does not # PHP Fatal error: Uncaught ReflectionException: Class flarum.config does not
# exist in /flarum/vendor/illuminate/container/Container.php # 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 -e "s|\['config' => \$app->make('flarum.config')\]|['config' => \$app->isInstalled() ? \$app->make('flarum.config') : []]|g" vendor/flarum/core/src/Console/Server.php
# Set permissions # Set permissions
chown -R flarum:flarum /flarum/app chown -R flarum:flarum .
# Install flarum (migrate database + assets) # if no installation was performed before
if [ ! -e 'assets/rev-manifest.json' ]; then
# 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 su-exec flarum:flarum php flarum install --file config.yml
# Define flarum settings in database # Define flarum settings in database
mysql -h"${DB_HOST}" -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" < config.sql 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 # Removing installation files
rm -f config.sql config.yml 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 ! # RUN !
exec supervisord -c /etc/supervisor/supervisord.conf exec supervisord -c /etc/supervisor/supervisord.conf

View File

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