Add the ability to install extensions

This commit is contained in:
Raoul Snyman 2023-10-18 21:46:59 -07:00
parent 0e451f0cdd
commit 9fa7b63665
3 changed files with 29 additions and 17 deletions

View File

@ -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 FROM php:apache
WORKDIR /flarum/app 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 mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN a2enmod rewrite RUN a2enmod rewrite
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
RUN apt-get update \ 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 \ && pecl install yaml \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \ && 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/make_config.php /flarum/make_config.php
COPY docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh 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 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 VOLUME /flarum/app/extensions /flarum/app/public/assets /flarum/app/storage/logs
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View File

@ -1,7 +1,8 @@
version: '3' version: '3'
services: services:
flarum: flarum:
image: git.snyman.info/raoul/flarum:latest # image: git.snyman.info/raoul/flarum:latest
build: .
environment: environment:
MYSQL_DATABASE: flarum MYSQL_DATABASE: flarum
MYSQL_USER: flarum MYSQL_USER: flarum
@ -17,14 +18,15 @@ services:
MAIL_ENCRYPTION: ssl MAIL_ENCRYPTION: ssl
MAIL_USERNAME: admin@example.com MAIL_USERNAME: admin@example.com
MAIL_PASSWORD: secret MAIL_PASSWORD: secret
EXTENSIONS: "fof/upload fof/nightmode fof/polls"
ports: ports:
- "8000:80" - "9000:80"
depends_on: depends_on:
- mysql - mysql
volumes: volumes:
- "./data/extensions:/flarum/app/extensions" - "./data/extensions:/flarum/app/extensions"
- "./data/assets:/flarum/app/public/assets" - "./data/assets:/flarum/app/public/assets"
- "./data/storage:/flarum/app/storage" - "./data/storage/logs:/flarum/app/storage/logs"
mysql: mysql:
image: mariadb:11 image: mariadb:11
environment: environment:

View File

@ -51,6 +51,26 @@ else
touch /flarum/app/public/assets/.installed.lock touch /flarum/app/public/assets/.installed.lock
fi 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` # first arg is `-f` or `--some-option`
if [[ "${1#-}" != "$1" ]]; then if [[ "${1#-}" != "$1" ]]; then
set -- apache2-foreground "$@" set -- apache2-foreground "$@"