-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.sh
executable file
·72 lines (61 loc) · 1.4 KB
/
stack.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
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
#!/bin/bash
# Author: Yonny Vizcaya
# Version: 1.0.0
# Description: Wrapper Scripts Automation Tool.
function create() {
if [[ ! -z ${1} ]]; then
echo "INFO - Creating Tech Stack"
docker-compose -f ${1} up -d
else
echo "Compose file not found. Please provide yml file."
fi
}
function destroy() {
if [[ ! -z ${1} ]]; then
echo "INFO - Destroying Tech Stack"
docker-compose -f ${1} down
else
echo "Compose file not found. Please provide yml file."
fi
}
function buildImage() {
local DOCKERFILE_PATH=${1}
docker build ${DOCKERFILE_PATH}
}
function pushImage() {
local IMAGE_NAME=${1}
local IMAGE_TAG=${2}
docker push localhost:5000/${IMAGE_NAME}:${IMAGE_TAG}
}
function pullImage() {
local IMAGE_NAME=${1}
docker pull ${IMAGE_NAME}
}
function tagImage() {
local IMAGE_NAME=${1}
docker tag ${IMAGE_NAME} ${IMAGE_NAME}:$(git rev-parse --short HEAD)
}
if [[ $# -gt 0 ]]; then
if [[ $1 == "create" ]]; then
create $2
fi
if [[ $1 == "destroy" ]]; then
destroy $2
fi
if [[ $1 == "buildImage" ]]; then
buildImage $2
fi
if [[ $1 == "pushImage" ]]; then
pushImage $2
fi
if [[ $1 == "pullImage" ]]; then
pullImage $2
fi
if [[ $1 == "tagImage" ]]; then
tagImage $2
fi
else
echo "
stack create [ -f: key-file-path ]
"
fi