summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-01-12 18:55:26 +0100
committerYorhel <git@yorhel.nl>2020-01-12 18:55:28 +0100
commit5b39f0d84bd58f75185b4901cf03fdbf55c73b62 (patch)
tree1a4e91258b92bcb7a5e47bdee38795ea5a5ccc42
parent5fd5479be1b72b5ebcdf44d320c64ac3f61b70a7 (diff)
Docker: Add image version check to docker-init.sh
This adds a method to signal that the docker image should be rebuilt after a change or update to the dependencies - which is much better than getting weird hard-to-debug errors because an older version of TUWF happens to be missing a function or something.
-rw-r--r--Dockerfile8
-rw-r--r--README.md3
-rwxr-xr-xutil/docker-init.sh15
3 files changed, 18 insertions, 8 deletions
diff --git a/Dockerfile b/Dockerfile
index 5150a9b7..855c9411 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,9 @@
FROM alpine:3.11
MAINTAINER Yoran Heling <contact@vndb.org>
+ENV VNDB_DOCKER_VERSION=1
+CMD /var/www/util/docker-init.sh
+
RUN apk add --no-cache \
build-base \
curl \
@@ -31,7 +34,4 @@ RUN apk add --no-cache \
Text::MultiMarkdown \
git://g.blicky.net/tuwf.git \
&& curl -sL https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz | zcat >/usr/bin/elm \
- && chmod 755 /usr/bin/elm \
- && touch /var/vndb-docker-image
-
-CMD /var/www/util/docker-init.sh
+ && chmod 755 /usr/bin/elm
diff --git a/README.md b/README.md
index 0a965040..61c76c0f 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,8 @@ util/multi.pl (application server, optional):
## Manual setup
- Make sure all the required dependencies (see above) are installed. Hint: See
- the Docker file for Ubuntu commands. For non-root setup: Use cpanm & local::lib.
+ the Docker file for Alpine Linux commands, other distributions will be similar.
+ For non-root setup, check out cpanminus & local::lib.
- Run the build system:
```
diff --git a/util/docker-init.sh b/util/docker-init.sh
index 7555fe51..4e34f753 100755
--- a/util/docker-init.sh
+++ b/util/docker-init.sh
@@ -1,8 +1,17 @@
#!/bin/sh
-if ! test -f /var/vndb-docker-image; then
- echo "This script should only be run from within the VNDB docker container."
- echo "Check the README for instructions."
+VER=`test -f /var/www/Dockerfile && grep VNDB_DOCKER_VERSION= /var/www/Dockerfile | sed -E s/^.+=//`
+
+if [ -z "$VER" -o -z "$VNDB_DOCKER_VERSION" -o "$VER" != "$VNDB_DOCKER_VERSION" ]; then
+ echo "The Docker image version ($VNDB_DOCKER_VERSION) does not match the version in the currently checked out source code ($VER)."
+ echo
+ echo "Please rebuild the Docker image and try again:"
+ echo
+ echo " docker rmi vndb"
+ echo " docker build -t vndb ."
+ echo
+ echo "Check README.md for instructions."
+ echo
exit 1
fi