diff --git a/Dockerfile b/Dockerfile index b217b21..ec72537 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,8 @@ RUN echo "@testing https://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/r && addgroup -g ${GID} flarum && adduser -h /flarum -s /bin/sh -D -G flarum -u ${UID} flarum \ && chown -R flarum:flarum /flarum \ && su-exec flarum:flarum composer create-project flarum/flarum /flarum/app $VERSION --stability=beta \ - && composer clear-cache + && composer clear-cache \ + && rm -rf /flarum/.composer COPY config.sql /flarum/app/config.sql COPY nginx.conf /etc/nginx/nginx.conf @@ -46,5 +47,6 @@ COPY supervisord.conf /etc/supervisor/supervisord.conf COPY startup /usr/local/bin/startup RUN chmod +x /usr/local/bin/startup +VOLUME /flarum/www EXPOSE 8080 CMD ["/usr/bin/tini","--","startup"] diff --git a/README.md b/README.md index 5125b22..a60e4ba 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ MAIL_PASS = xxxxxxxx ### Volume -* /flarum : Flarum directory +* /flarum/www : Flarum directory ### Docker-compose @@ -67,7 +67,7 @@ flarum: - MAIL_PASS=zzzzzzzz - MAIL_ENCR=ssl volumes: - - /mnt/docker/flarum:/flarum + - /mnt/docker/flarum:/flarum/www mariadb: image: mariadb:10.1 @@ -79,7 +79,6 @@ mariadb: - MYSQL_DATABASE=flarum - MYSQL_USER=flarum - MYSQL_PASSWORD=yyyyyyyy - ``` #### Run ! @@ -95,4 +94,4 @@ docker-compose up -d ### Configuration file -The main configuration file is located here : **/mnt/docker/flarum/config.php** +The main configuration file is located here : **/mnt/docker/flarum/app/config.php** diff --git a/nginx.conf b/nginx.conf index ab9b74e..e77ddf3 100644 --- a/nginx.conf +++ b/nginx.conf @@ -48,7 +48,7 @@ http { server { listen 8080; - root /flarum/app; + root /flarum/www/app; index index.php; access_log /var/log/nginx/access.log; diff --git a/startup b/startup index 995f031..412bd89 100644 --- a/startup +++ b/startup @@ -10,10 +10,12 @@ if [ -z "$FORUM_URL" ]; then exit 1 fi -if [ ! -e '/flarum/app/config.php' ]; then +# if no installation was performed before +if [ ! -e '/flarum/www/app/config.php' ]; then cd /flarum/app/ +# Flarum settings cat > config.yml < \$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 +chown -R flarum:flarum /flarum/app # Install flarum (migrate database + assets) su-exec flarum:flarum php flarum install --file config.yml @@ -49,12 +51,21 @@ 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 +# 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 permissions -chown -R flarum:flarum /flarum +# Set web directory permissions +chown -R flarum:flarum /flarum/www # RUN ! supervisord -c /etc/supervisor/supervisord.conf