From 9fa7b63665cf3f471da83b8e942c9eb663c4e49d Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 18 Oct 2023 21:46:59 -0700 Subject: [PATCH] Add the ability to install extensions --- Dockerfile | 18 ++++-------------- docker-compose.yml | 8 +++++--- docker/docker-entrypoint.sh | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 13369bb..33d8231 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,3 @@ -FROM php:cli AS build - -WORKDIR /flarum/app - -RUN apt-get update && apt-get install -y git zip unzip p7zip -RUN cd /tmp \ - && curl --progress-bar http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ - && chmod +x /usr/local/bin/composer -RUN composer create-project flarum/flarum /flarum/app - - FROM php:apache WORKDIR /flarum/app @@ -20,8 +9,9 @@ RUN sed -ri -e 's!AllowOverride [Nn]one!AllowOverride All!' /etc/apache2/sites-a RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" RUN a2enmod rewrite +COPY --from=composer /usr/bin/composer /usr/local/bin/composer RUN apt-get update \ - && apt-get install -y gettext libfreetype-dev libjpeg62-turbo-dev libpng-dev libpq5 libpq-dev mariadb-client libyaml-0-2 libyaml-dev \ + && apt-get install -y gettext git libfreetype-dev libjpeg62-turbo-dev libpng-dev libpq5 libpq-dev mariadb-client libyaml-0-2 libyaml-dev p7zip unzip zip \ && pecl install yaml \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \ @@ -32,9 +22,9 @@ RUN apt-get update \ COPY docker/make_config.php /flarum/make_config.php COPY docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -COPY --from=build /flarum/app /flarum/app -RUN chown -R www-data:www-data /flarum RUN chmod a+x /usr/local/bin/docker-entrypoint.sh +RUN composer create-project flarum/flarum /flarum/app +RUN chown -R www-data:www-data /flarum VOLUME /flarum/app/extensions /flarum/app/public/assets /flarum/app/storage/logs ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index b1eb937..c8a5e60 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ version: '3' services: flarum: - image: git.snyman.info/raoul/flarum:latest + # image: git.snyman.info/raoul/flarum:latest + build: . environment: MYSQL_DATABASE: flarum MYSQL_USER: flarum @@ -17,14 +18,15 @@ services: MAIL_ENCRYPTION: ssl MAIL_USERNAME: admin@example.com MAIL_PASSWORD: secret + EXTENSIONS: "fof/upload fof/nightmode fof/polls" ports: - - "8000:80" + - "9000:80" depends_on: - mysql volumes: - "./data/extensions:/flarum/app/extensions" - "./data/assets:/flarum/app/public/assets" - - "./data/storage:/flarum/app/storage" + - "./data/storage/logs:/flarum/app/storage/logs" mysql: image: mariadb:11 environment: diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index c04214f..ca6982a 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -51,6 +51,26 @@ else touch /flarum/app/public/assets/.installed.lock fi +# Change into the flarum directory so that we can do a number of tasks +cd /flarum/app + +echo "Installing extensions..." +if [[ "$EXTENSIONS" != "" ]]; then + # install extensions + for EXT in $EXTENSIONS; do + composer require $EXT:"*" + done +fi + +# Always run migrate and clear the cache +echo "Running any pending migrations and clearing the cache..." +php flarum migrate +if [[ -d "/flarum/app/storage/cache" ]]; then + php flarum cache:clear +fi + +chown www-data:www-data -R /flarum/* + # first arg is `-f` or `--some-option` if [[ "${1#-}" != "$1" ]]; then set -- apache2-foreground "$@"