From 4c7b78a991d5e5929afe123245e824c06c12a8ac Mon Sep 17 00:00:00 2001 From: Hardware Date: Fri, 2 Dec 2016 08:23:11 +0100 Subject: [PATCH] feat(): add composer custom repository system --- Dockerfile | 2 +- README.md | 63 ++++++++++-------------------------------------------- extension | 6 ++++-- run.sh | 16 +++++++++----- 4 files changed, 27 insertions(+), 60 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea1c76b..1b3c3e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ COPY run.sh /usr/local/bin/run.sh RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* -VOLUME /flarum/app/assets +VOLUME /flarum/app/assets /flarum/app/extensions EXPOSE 8888 diff --git a/README.md b/README.md index bfe928d..20e16c3 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,8 @@ flarum: - FORUM_URL=https://forum.domain.tld - DB_PASS=xxxxxxxx volumes: - - /mnt/docker/flarum:/flarum/app/assets + - /mnt/docker/flarum/assets:/flarum/app/assets + - /mnt/docker/flarum/extensions:/flarum/app/extensions mariadb: image: mariadb:10.1 @@ -136,66 +137,24 @@ docker exec -ti flarum extension list ### Custom error pages -To use custom error pages, add your .html files in `/mnt/docker/flarum/errors` folder : +To use custom error pages, add your .html files in `/mnt/docker/flarum/assets/errors` folder : ``` -mkdir -p /mnt/docker/flarum/errors +mkdir -p /mnt/docker/flarum/assets/errors touch 403.html 404.html 500.html 503.html chown -R 991:991 /mnt/docker/flarum ``` -### Custom composer.json (experienced users) +### Custom composer repositories -Customize your own composer.json file in `/mnt/docker/flarum/composer.custom.json`, for example add some privates repositories like this : +To use the composer repository system, add your repo name and json representation in `/mnt/docker/flarum/extensions/composer.repositories.txt` : -```json -# /mnt/docker/flarum/composer.custom.json -{ - "name": "flarum/flarum", - "description": "Delightfully simple forum software.", - [...] - - "repositories": [ - { - "type": "package", - "package": { - "name": "xxxxx/flarum-ext-my-private-extension", - "version": "dev-master", - "type": "flarum-extension", - "authors": [ - { - "name": "Me", - "email": "me@domain.tld" - } - ], - "dist": { - "url": "/flarum/app/assets/extensions/flarum-ext-my-private-extension", - "type": "path", - "reference": "master" - }, - "require": { - "flarum/core": "^0.1.0-beta.6" - }, - "autoload": { - "psr-4": { - "xxx\\xxx\\": "src/" - } - }, - "extra": { - "flarum-extension": { - "title": "xxxxxx", - "icon": { - "name": "picture-o", - "backgroundColor": "#2196f3", - "color": "#fff" - } - } - } - } - } - ], -} ``` +my_private_repo|{"type":"path","url":"extensions/*/"} +my_public_repo|{"type":"vcs","url":"https://github.com/my/repo"} +``` + +https://getcomposer.org/doc/03-cli.md#modifying-repositories ### Screenshot diff --git a/extension b/extension index 3eb0b2e..3dccbfb 100644 --- a/extension +++ b/extension @@ -9,8 +9,8 @@ CRED="${CSI}1;31m" CGREEN="${CSI}1;32m" # Composer cache dir and packages list paths -CACHE_DIR=/flarum/app/assets/.extensions -LIST_FILE=assets/.extensions/list +CACHE_DIR=extensions/.cache +LIST_FILE=extensions/list # Cmd ARGS action=$1 @@ -55,4 +55,6 @@ case "$action" in ;; esac +su-exec $UID:$GID php flarum cache:clear + exit 0 diff --git a/run.sh b/run.sh index 0a4ad5d..36c6400 100644 --- a/run.sh +++ b/run.sh @@ -30,13 +30,19 @@ cd /flarum/app # Custom HTTP errors pages if [ -d 'assets/errors' ]; then + echo "[INFO] Found custom errors pages" rm -rf vendor/flarum/core/error/* ln -s /flarum/app/assets/errors/* vendor/flarum/core/error fi -# Custom composer.json (eg. for privates extensions) -if [ -f 'assets/composer.custom.json' ]; then - cp -f assets/composer.custom.json composer.json +# Custom repositories (eg. for privates extensions) +if [ -f 'extensions/composer.repositories.txt' ]; then + while read line; do + repository=$(echo $line | cut -d '|' -f1) + json=$(echo $line | cut -d '|' -f2) + echo "[INFO] Adding ${repository} composer repository" + composer config repositories.${repository} "${json}" + done < extensions/composer.repositories.txt fi # if no installation was performed before @@ -55,8 +61,8 @@ if [ -e 'assets/rev-manifest.json' ]; then su-exec $UID:$GID php flarum cache:clear # Composer cache dir and packages list paths - CACHE_DIR=assets/.extensions - LIST_FILE=$CACHE_DIR/list + CACHE_DIR=extensions/.cache + LIST_FILE=extensions/list # Download extra extensions installed with composer wrapup script if [ -s "$LIST_FILE" ]; then