Skip to content

Commit 871047b

Browse files
authored
Merge pull request #9 from megan-starr9/master
Add an optional flag to preserve existing files
2 parents 6395f75 + 147203f commit 871047b

2 files changed

Lines changed: 45 additions & 4 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ Note, you'll also need a virtual host configuration file for the provided `nginx
6060

6161
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.
6262

63+
# Preserving existing files
64+
65+
If you wish to run this image and preserve any updated `lang` or `config` files, you can add the following flag:
66+
67+
```
68+
docker run mybb/mybb --skip-old-files php-fpm
69+
```
70+
71+
or, within your compose file, specify the following command argument:
72+
73+
```yaml
74+
services:
75+
mybb:
76+
image: mybb/mybb:latest
77+
command: --skip-old-files php-fpm
78+
volumes:
79+
- ${PWD}/mybb:/var/www/html:rw
80+
81+
...
82+
```
83+
6384
# How to build this image
6485

6586
You must provide four build-time arguments when building this Docker image; `BUILD_AUTHORS`, `BUILD_DATE`, `BUILD_SHA512SUM` and `BUILD_VERSION`.

docker-entrypoint.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
#!/usr/bin/env sh
22
set -euo pipefail
33

4+
SKIP_OLD_FILES=false
5+
6+
# Loop through arguments and process them
7+
for arg in "$@"; do
8+
case $arg in
9+
--skip-old-files)
10+
SKIP_OLD_FILES=true
11+
shift # Remove --skip-verification from `$@`
12+
;;
13+
*)
14+
break
15+
;;
16+
esac
17+
done
18+
419
if ! [ -e index.php -a -e inc/class_core.php ]; then
520
echo >&2 "MyBB not found in $PWD - copying now..."
6-
if [ "$(ls -A)" ]; then
7-
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
8-
( set -x; ls -A; sleep 10 )
21+
if [[ $SKIP_OLD_FILES == true ]]; then
22+
echo >&2 "Preserving existing directory files..."
23+
tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf - --skip-old-files
24+
else
25+
if [ "$(ls -A)" ]; then
26+
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
27+
( set -x; ls -A; sleep 10 )
28+
fi
29+
tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf -
930
fi
10-
tar cf - --one-file-system -C /usr/src/mybb-mybb_${MYBB_VERSION} . | tar xf -
1131
echo >&2 "Complete! MyBB ${MYBB_VERSION} has been successfully copied to $PWD"
1232
fi
1333

0 commit comments

Comments
 (0)