-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_run
49 lines (41 loc) · 1.46 KB
/
local_run
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
#!/bin/bash
# SPDX-FileCopyrightText: Alliander N. V.
#
# SPDX-License-Identifier: Apache-2.0
SCRIPT_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
pwd -P
)
IMAGE_TAG="local"
images=()
for dockerfile in $SCRIPT_PATH/dockerfiles/*.Dockerfile; do
images+=("$(basename "${dockerfile%.*}")")
done
[[ -z $images ]] && echo "No Dockerfiles found" && return 1
echo "Select image #: "
select image in "${images[@]}" ; do
[[ $image ]] && break
done
image_slash="${image/rcdt_/rcdt\/}"
if [ -z "$(docker images -q $image_slash:$IMAGE_TAG 2> /dev/null)" ]; then
cache_options=(true false)
echo "Build with cache?"
select use_cache in "${cache_options[@]}" ; do
[[ $use_cache ]] && break
done
use_cache=$(! "$use_cache" && echo "--no-cache" || echo "")
sequential_options=(parallel sequential)
echo "Colcon build style: "
select colcon_build_sequential in "${sequential_options[@]}" ; do
[[ $colcon_build_sequential ]] && break
done
COLCON_BUILD_SEQUENTIAL=$([ "$colcon_build_sequential" == "sequential" ] && echo "true" || echo "false")
docker build \
$use_cache \
--build-arg COLCON_BUILD_SEQUENTIAL="$COLCON_BUILD_SEQUENTIAL" \
-t "$image_slash:$IMAGE_TAG" \
-f "$SCRIPT_PATH/dockerfiles/$image.Dockerfile" \
"$SCRIPT_PATH/dockerfiles"
fi
echo Running $image:$IMAGE_TAG ...
IMAGE_TAG=$IMAGE_TAG docker compose -f $SCRIPT_PATH/.devcontainer/docker-compose.yml run --rm $image