-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker.sh
executable file
·34 lines (29 loc) · 1 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
usage() {
echo >&2 "Usage: $0 [build|demo]
To run the demo you need to build the docker container once using '$0 build'.
Afterwards, you can run '$0 demo'."
exit 1
}
if [ $# -ne 1 ]
then
usage
fi
case "$1" in
build)
# Check if Nix is installed and try to build the Docker container with Nix.
# If Nix is not installed or the build failed due to any reason, try to
# build with Docker.
(
( which nix &>/dev/null && nix-build nix/docker.nix && docker load < result ) ||
docker build . --tag diffdetective-demo:1.0.0
) && echo "Docker container successfully built." || echo "Failed to build the docker container."
;;
demo)
docker run --rm --net=host --volume="$HOME/.Xauthority:/home/user/.Xauthority:rw" -e _JAVA_AWT_WM_NONREPARENTING="$_JAVA_AWT_WM_NONREPARENTING" -e DISPLAY="${DISPLAY:-:0}" --volume="$PWD/data/output:/home/user/data/output:rw" diffdetective-demo:1.0.0
;;
*)
usage
;;
esac