-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-execution.sh
More file actions
64 lines (53 loc) · 1.94 KB
/
start-execution.sh
File metadata and controls
64 lines (53 loc) · 1.94 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# execution: bash ./start-execution.sh [custom/clean] infer test1 input_file
DOCKER_BASE=$1
TOOL=$2
INSTANCE_NAME=$3
INPUT_FILE=$4
RECORD_DATA=$5
if [ $DOCKER_BASE == "custom" ]; then
IMAGE_NAME="jammy-base"
elif [ $DOCKER_BASE == "clean" ]; then
IMAGE_NAME="clean-base"
else
echo "try: bash ./start-execution.sh [custom|clean] [tool_name] [instance_name] [input_file] [record_data:yes|no]"
exit -1
fi
if [ $RECORD_DATA == "yes"]; then
USE_DATABASE="yes"
else
USE_DATABASE="no"
fi
echo "setting up a docker instance for $TOOL as $INSTANCE_NAME"
echo "choosing base: $DOCKER_BASE"
echo "input file: $INPUT_FILE"
echo "instance name: $INSTANCE_NAME"
echo "use database: $USE_DATABASE"
# start database container, if needed : auto-tool-investigation-db
# docker-compose -f docker/database.yml up -d
# build custom docker if not exists
EXISTING_IMAGE=$( docker images -q $IMAGE_NAME )
if [[ -n "$EXISTING_IMAGE" ]]; then
echo "$IMAGE_NAME image exists, launching a new instance"
else
echo "build base image"
if [ $IMAGE_NAME == "jammy-base" ]; then
docker build -t "$IMAGE_NAME" -f script/tool/Dockerfile-Base .
elif [ $IMAGE_NAME == "clean-base" ]; then
docker build -t "$IMAGE_NAME" -f script/tool/Dockerfile-Clean-Base .
fi
fi
# create output directory on host
mkdir -m 777 ./output/$INSTANCE_NAME
# run common docker with the instance name
# attach volume in host output path,
# also attach data, tool, script folder for hot-reload from host
docker run -d --network=host \
--cpus=4 \
--name $INSTANCE_NAME \
--log-driver json-file --log-opt max-size=5m --log-opt max-file=10 \
-v "$PWD/output/$INSTANCE_NAME":/home/ubuntu/workspace/output:rw \
-v "$PWD/script":/home/ubuntu/workspace/script:ro \
-v "$PWD/data-ref":/home/ubuntu/workspace/data-ref:ro \
$IMAGE_NAME \
bash /home/ubuntu/workspace/script/tool/$TOOL/entrypoint.sh $INSTANCE_NAME $INPUT_FILE $USE_DATABASE