-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·82 lines (72 loc) · 2.57 KB
/
run
File metadata and controls
executable file
·82 lines (72 loc) · 2.57 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# See the USAGE message below for commands.
#------------------------------------------------------------------------------
set -e
############################################################
# Config
############################################################
DOCKER_IMAGE_NAME="lucidchart/resource-count"
DOCKER_BUILD_CMD="docker build . -t $DOCKER_IMAGE_NAME"
DOCKER_RUN_CMD="docker run -it --rm -v $HOME/.aws:/root/.aws -v $PWD:/aws"
############################################################
# Usage
############################################################
if [[ $# -lt 1 ]]; then
echo
echo "USAGE: ./run.sh [COMMAND]"
echo
echo "Commands:"
echo " setup - Setup the initial dev env by building the necessary"
echo " Docker container."
echo
echo " count <params> - Run the resource counting script. Params:"
echo " --profile <name> --regions <region1> <region2> -c"
echo
echo " exec - Run a one-off command in a container."
echo
echo " shell - Run a bash shell in a container."
echo
echo "######################################################################"
echo "NOTE: This script requires that you have Docker installed."
echo
echo "NOTE: You must have first used 'aws configure --profile <name>' to"
echo " configure AWS credentials that are mounted into the container."
echo "######################################################################"
echo
exit
fi
############################################################
# Main Script
############################################################
while [[ $# -gt 0 ]]; do
param="$1"
shift
case "$param" in
setup)
echo
echo "######################################################################"
echo "# Building '$DOCKER_IMAGE_NAME' Docker image..."
echo "######################################################################"
echo
$DOCKER_BUILD_CMD
break
;;
count)
$DOCKER_RUN_CMD $DOCKER_IMAGE_NAME $@
break
;;
exec)
$DOCKER_RUN_CMD --entrypoint /bin/bash $DOCKER_IMAGE_NAME -c $@
break
;;
shell|bash)
$DOCKER_RUN_CMD --entrypoint /bin/bash $DOCKER_IMAGE_NAME -l
break
;;
*)
echo "Unknown command: $param"
break
;;
esac
done