diff --git a/README.md b/README.md index 739b9b3..f4ca4e1 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,27 @@ Note, you'll also need a virtual host configuration file for the provided `nginx You should note that static content such as images and JavaScript or CSS files must be cross-mounted between the `mybb` and `nginx` containers - as PHP-FPM is not capable of serving those natively. +# Preserving existing files + +If you wish to run this image and preserve any updated `lang` or `config` files, you can add the following flag: + +``` +docker run mybb/mybb --skip-old-files php-fpm +``` + +or, within your compose file, specify the following command argument: + +```yaml +services: + mybb: + image: mybb/mybb:latest + command: --skip-old-files php-fpm + volumes: + - ${PWD}/mybb:/var/www/html:rw + + ... +``` + # How to build this image You must provide four build-time arguments when building this Docker image; `BUILD_AUTHORS`, `BUILD_DATE`, `BUILD_SHA1SUM` and `BUILD_VERSION`. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 390446a..8887d55 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,13 +1,33 @@ #!/usr/bin/env sh set -euo pipefail +SKIP_OLD_FILES=false + +# Loop through arguments and process them +for arg in "$@"; do + case $arg in + --skip-old-files) + SKIP_OLD_FILES=true + shift # Remove --skip-verification from `$@` + ;; + *) + break + ;; + esac +done + if ! [ -e index.php -a -e inc/class_core.php ]; then echo >&2 "MyBB not found in $PWD - copying now..." - if [ "$(ls -A)" ]; then - echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" - ( set -x; ls -A; sleep 10 ) + if [[ $SKIP_OLD_FILES == true ]]; then + echo >&2 "Preserving existing directory files..." + tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf - --skip-old-files + else + if [ "$(ls -A)" ]; then + echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!" + ( set -x; ls -A; sleep 10 ) + fi + tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf - fi - tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf - echo >&2 "Complete! MyBB ${MYBB_VERSION} has been successfully copied to $PWD" fi