-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·91 lines (79 loc) · 2.82 KB
/
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
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
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# This script is a common utility for running various commands on this
# repository in a development environment, including setup tasks for a new
# development environment, and tasks that wrap docker and docker-compose to run
# the service, its dependencies, and other management scripts inside containers.
#
# See the USAGE message below for commands.
#------------------------------------------------------------------------------
set -e
############################################################
# Config
############################################################
DOCKER_IMAGE_NAME="facetdigital/aws-cli-tools"
DOCKER_BUILD_CMD="docker build . -t $DOCKER_IMAGE_NAME"
DOCKER_RUN_CMD="docker run -it --rm -v $(pwd)/app:/app -v $(pwd)/.aws:/root/.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 " route53:dump-zone <HostedZoneID>"
echo " Dumps JSON data for all DNS records in a Hosted Zone."
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
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
;;
route53:dump-zone)
zone_id="$1"
shift
$DOCKER_RUN_CMD $DOCKER_IMAGE_NAME aws route53 list-resource-record-sets --hosted-zone-id $zone_id
;;
exec)
$DOCKER_RUN_CMD $DOCKER_IMAGE_NAME $@
break
;;
execd)
$DOCKER_RUND_CMD $DOCKER_IMAGE_NAME $@
break
;;
shell|bash)
$DOCKER_RUN_CMD $DOCKER_IMAGE_NAME bash
break
;;
*)
echo "Unknown command: $param"
break
;;
esac
done