feat(): add composer custom repository system

pull/3/head
Hardware 2016-12-02 08:23:11 +01:00
parent d2146d736e
commit 4c7b78a991
No known key found for this signature in database
GPG Key ID: EC6DF6F90263EDEA
4 changed files with 27 additions and 60 deletions

View File

@ -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

View File

@ -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

View File

@ -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

16
run.sh
View File

@ -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