-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·44 lines (33 loc) · 1020 Bytes
/
run.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
#!/bin/bash
target_environment=$1
if [ -z "$1" ]
then
echo "target environment (either development or production) is required"
exit 1
fi
if [ ! $target_environment == development ] && [ ! $target_environment == production ]
then
echo "invalid target environment"
exit 1
fi
target_image_name=hurb-challenge-charlie
target_image_name_with_tag=$target_image_name:$target_environment
image="$(docker images | grep $target_image_name) | grep $target_environment"
function build_image() {
docker build --target $target_environment -t $target_image_name_with_tag .
}
function create_container_and_run() {
docker run -it $([[ $target_environment == development ]] && echo --network=host) -v $(pwd)/src:/$target_image_name/src $target_image_name_with_tag
}
echo
echo "****************************"
echo "Building image"
echo "****************************"
echo
build_image
echo
echo "****************************"
echo "Creating container"
echo "****************************"
echo
create_container_and_run