Minor fixes based on comments to PR #9.

Changes included:

* Obtain the current dokuwiki released from the DOKUWIKI_VERSION
environment variable set in the Dockerfile.
* Only unpack the bundled dokuwiki release if we actually need to
copy over new files.
* Clean up the temporary copy of dokuwiki when we are done copying files
from it.
* Use `exec` to run the http server at the end of the startup script.
* Document the `donwgrade` and `overwrite` comamnds.
master
Andrei Poenaru 7 years ago
parent b7bc34a36c
commit bf5bf36e2f
  1. 2
      Dockerfile
  2. 10
      README.md
  3. 23
      docker-startup.sh

@ -9,7 +9,7 @@ FROM ubuntu:16.04
MAINTAINER Miroslav Prasil <miroslav@prasil.info> MAINTAINER Miroslav Prasil <miroslav@prasil.info>
# Set the version you want of Twiki # Set the version you want of Twiki
ARG DOKUWIKI_VERSION=2017-02-19e ENV DOKUWIKI_VERSION=2017-02-19e
ARG DOKUWIKI_CSUM=09bf175f28d6e7ff2c2e3be60be8c65f ARG DOKUWIKI_CSUM=09bf175f28d6e7ff2c2e3be60be8c65f
# Update & install packages & cleanup afterwards # Update & install packages & cleanup afterwards

@ -59,6 +59,16 @@ afterwards you can remove data container if you want
Just stop the old container and run the new one with the same `-v` mapping. Since the data is on your file system, you do not need to do anything special to preserve it between containers. Just stop the old container and run the new one with the same `-v` mapping. Since the data is on your file system, you do not need to do anything special to preserve it between containers.
#### Handling changes in bundled files inside volumes ####
If you mount a volume that has previously been used with a newer version of DokuWiki than that installed in the current contaier, the newer files will _not_ be overwritten by those bundled with the current (older) version of DokuWiki. If you want to force a downgrade (at your own risk!), run the container with the `downgrade` command:
docker run ... mprasil/dokuwiki donwgrade
Additionally, if you make any changes to the files bundled with DokuWiki that are located in your volumes, these can be restored to the original version using the `overwrite` command:
docker run ... mprasil/dokuwiki overwrite
Optimizing your wiki Optimizing your wiki
-------------------- --------------------

@ -10,19 +10,15 @@ set -o pipefail
# or fully populate these folders if this is the first run. # or fully populate these folders if this is the first run.
dokudir=/dokuwiki dokudir=/dokuwiki
tmpdir=/tmp/dokuwiki
verfile=.last-version verfile=.last-version
containerver="$(date -f <(echo "$DOKUWIKI_VERSION" | tr -d '[:alpha:]') +%s)"
if [ ! -d "$dokudir" ]; then if [ ! -d "$dokudir" ]; then
echo "DokuWiki does not appear to be installed correctly at: $dokudir." >&2 echo "DokuWiki does not appear to be installed correctly at: $dokudir." >&2
exit 1 exit 1
fi fi
# Unpack a temporary copy
tmpdir=/tmp/dokuwiki
mkdir "$tmpdir"
tar -zxf /dokuwiki.tgz -C "$tmpdir" --strip-components 1
containerver="$(date -f <(awk '{print $1}' "$tmpdir/VERSION" | tr -d '[:alpha:]') +%s)"
# Check for downgrade/overwrite parameters # Check for downgrade/overwrite parameters
if [ "$1" = 'downgrade' ]; then downgrade=1; else downgrade=0; fi if [ "$1" = 'downgrade' ]; then downgrade=1; else downgrade=0; fi
if [ "$1" = 'overwrite' ]; then overwrite=1; else overwrite=0; fi if [ "$1" = 'overwrite' ]; then overwrite=1; else overwrite=0; fi
@ -40,7 +36,13 @@ if [ "$1" = 'run' ] || [ "$1" = 'downgrade' ] || [ "$1" = 'overwrite' ]; then
# Do nothing for equal versions # Do nothing for equal versions
continue continue
elif [ "$volumever" -lt "$containerver" ] || [ "$downgrade" -eq 1 ] || [ "$overwrite" -eq 1 ]; then elif [ "$volumever" -lt "$containerver" ] || [ "$downgrade" -eq 1 ] || [ "$overwrite" -eq 1 ]; then
# Update if the container version is newer than the volume version # First, unpack a temporary copy of the current DokuWiki version
if [ ! -d "$tmpdir" ]; then
mkdir "$tmpdir"
tar -zxf /dokuwiki.tgz -C "$tmpdir" --strip-components 1
fi
# Then, update if the container version is newer than the volume version
# Or if overridden using `downgrade` # Or if overridden using `downgrade`
echo "Migrating $d..." echo "Migrating $d..."
cp -r "$tmpdir/$d/"* "$dokudir/$d/" cp -r "$tmpdir/$d/"* "$dokudir/$d/"
@ -50,17 +52,20 @@ if [ "$1" = 'run' ] || [ "$1" = 'downgrade' ] || [ "$1" = 'overwrite' ]; then
cat >&2 <<EOM cat >&2 <<EOM
This volume has perviously been used with a newer version of DokuWiki. This volume has perviously been used with a newer version of DokuWiki.
If you want to force a downgrade (at your own risk!), run the \`downgrade\` command: If you want to force a downgrade (at your own risk!), run the \`downgrade\` command:
docker run ... andreipoe/dokuwiki donwgrade docker run ... mprasil/dokuwiki donwgrade
EOM EOM
exit 2 exit 2
fi fi
done done
# Clean up any temporary files
rm -rf "$tmpdir"
# Ensure persmissions are set correctly # Ensure persmissions are set correctly
chown -R www-data:www-data "$dokudir" chown -R www-data:www-data "$dokudir"
# Run the web server # Run the web server
/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf exec /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
else else
# Handle custom commands otherwise # Handle custom commands otherwise
exec "$@" exec "$@"

Loading…
Cancel
Save