diff --git a/Dockerfile b/Dockerfile index c7744e3..a7750f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,6 +108,14 @@ RUN set -eux; \ WORKDIR /var/www/html +COPY scripts /var/scripts + +RUN chmod +x \ + /var/scripts/demo-importing.sh \ + /var/scripts/logo.sh \ + /var/scripts/observe.sh \ + /var/scripts/sync.sh + RUN mkdir -p _assets images \ importing/no-parse \ importing/parse-albums \ @@ -115,8 +123,4 @@ RUN mkdir -p _assets images \ COPY --chown=www-data chevereto/ . -RUN composer install \ - --working-dir=app \ - --no-progress - RUN chown www-data: . -R && ls -la diff --git a/scripts/chevereto.sh b/scripts/chevereto.sh index f1e92f1..69b6de3 100755 --- a/scripts/chevereto.sh +++ b/scripts/chevereto.sh @@ -2,7 +2,7 @@ set -e DOWNLOAD_DIR=${PWD}"/.temp" WORKING_DIR=${PWD}"/chevereto" -PACKAGE=${VERSION}"-lite" +PACKAGE=${VERSION} API_DOWNLOAD="https://chevereto.com/api/download/" echo "* Downloading Chevereto" rm -rf $DOWNLOAD_DIR $WORKING_DIR diff --git a/scripts/demo-importing.sh b/scripts/demo-importing.sh new file mode 100755 index 0000000..d57a939 --- /dev/null +++ b/scripts/demo-importing.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e +curl -S -o /var/www/html/importing/importing.tar.gz -L "https://codeload.github.com/chevereto/demo-importing/tar.gz/refs/heads/main" + +tar -xf /var/www/html/importing/importing.tar.gz -C /var/www/html/importing/ && + rm -rf /var/www/html/importing/importing.tar.gz && + rsync -a /var/www/html/importing/demo-importing-main/ /var/www/html/importing/ && + rm -rf /var/www/html/importing/demo-importing-main + +chown www-data: /var/www/html/importing/ -R diff --git a/scripts/observe.sh b/scripts/observe.sh new file mode 100755 index 0000000..1a22caa --- /dev/null +++ b/scripts/observe.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -e +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) +. $SCRIPT_DIR/sync.sh +inotifywait \ + --event create \ + --event delete \ + --event modify \ + --event move \ + --format "%e %w%f" \ + --exclude $EXCLUDE \ + --monitor \ + --recursive \ + $SOURCE | + while read CHANGED; do + sync + done diff --git a/scripts/sync.sh b/scripts/sync.sh new file mode 100755 index 0000000..2420086 --- /dev/null +++ b/scripts/sync.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +SOURCE=/var/www/chevereto/ +TARGET=/var/www/html/ +EXCLUDE="\.git|\.DS_Store|\.well-known|\.vscode|\/app\/vendor|\/app\/env\.php|\/app\/importer\/jobs" +rsync --mkpath -a "${SOURCE}"app/vendor/ "${TARGET}"app/vendor/ +cp "${SOURCE}".gitignore "${TARGET}".gitignore +function sync() { + rsync -r -I -og \ + --chown=www-data:www-data \ + --info=progress2 \ + --filter=':- .gitignore' \ + --exclude '.git' \ + --exclude '.well-known' \ + --exclude '_assets/' \ + --delete \ + $SOURCE $TARGET +} +sync