-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_build.sh
executable file
·51 lines (45 loc) · 1.03 KB
/
docker_build.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
45
46
47
48
49
50
51
#!/bin/bash
# default name for the container
NAME=defending_privacy_using_backdoors
WANDB_KEY=""
help() {
# display the help text
echo "This script builds a docker image using the Dockerfile."
echo
echo "Usage: docker_build.sh [OPTION...]"
echo
echo "options:"
echo "-n, --name Specify a name for the Docker image. (Default: ${NAME})"
echo "-w, --wandb Specify your Weights and Biases API key to use WandB within the Docker container."
echo "-h, --help Prints help."
}
POSITIONAL=()
while [ $# -gt 0 ]; do
key="$1"
case $key in
-n|--name)
NAME="$2"
shift # passed argument
shift # passed value
;;
-w|--wandb)
WANDB_KEY="$2"
shift
shift
;;
-h|--help)
help
exit 0
;;
*)
echo "Argument '$key' unknown"
exit 1
;;
esac
done
set -- "${POSITIONAL[@]}"
echo "Image name: ${NAME}"
if [ -n "${WANDB_KEY}" ] ; then
echo "WandB API key: ${WANDB_KEY}"
fi
docker build -t "${NAME}" --build-arg WANDB_KEY="${WANDB_KEY}" .