-
Notifications
You must be signed in to change notification settings - Fork 4
/
nix-docker-build-and-load.sh
executable file
·45 lines (38 loc) · 1.09 KB
/
nix-docker-build-and-load.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
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
if [[ "$#" -eq 1 && "$1" == "--help" ]]; then
cat <<EOF
usage:
$0
$0 echo-output -> just echo the output file, that will be generated
$0 echo-tag -> just echo the tag, that the image will have in the local registry
$0 run -> run the server after build, using ./docker-run.sh
This
- builds the image using nix
- loads the image into the local docker registry
- optionally runs the image
EOF
exit 0
fi
output=ldbcollector.tar.gz
if [[ $# -eq 1 && "$1" == "echo-output" ]]; then
echo "$output"
exit 0
fi
docker="docker"
tag="maxhbr/ldbcollector:latest"
if command -v "podman" &> /dev/null; then
>&2 echo "use podman"
docker="podman"
tag="localhost/maxhbr/ldbcollector:latest"
fi
if [[ $# -eq 1 && "$1" == "echo-tag" ]]; then
echo "$tag"
exit 0
fi
nix build -o "$output" .#ldbcollector-image
$docker load --input "$output"
if [[ $# -eq 1 && "$1" == "run" ]]; then
./docker-run.sh "$tag"
fi