forked from spryker/docker-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk
executable file
·94 lines (75 loc) · 2.54 KB
/
sdk
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
92
93
94
#!/bin/bash
set -e
pushd "${BASH_SOURCE%/*}" > /dev/null
. bin/constants.sh
. bin/console.sh
. bin/check-directories.sh
. bin/boot-deployment.sh
popd > /dev/null
PROJECT_NAME=default
while getopts "vp:" opt;
do
case ${opt} in
v)
VERBOSE=1
;;
p)
PROJECT_NAME=$OPTARG
if [ "${PROJECT_NAME}" != "${PROJECT_NAME%[[:space:]]*}" ];
then
error "${WARN}The project name cannot contain spaces.${NC}"
exit 1
fi
;;
*)
;;
esac
done
shift $((OPTIND -1))
DESTINATION_DIR=${DESTINATION_DIR:-"${BASH_SOURCE%/*}/deployment/${PROJECT_NAME}"}
DEPLOYMENT_DIR="${BASH_SOURCE%/*}/deployment/_tmp"
readonly DEPLOY_SCRIPT=${DESTINATION_DIR}/deploy
function showHelp()
{
echo -e ""
echo -e "${INFO}Installation:${NC}"
echo -e " $0 [-v] [-p <project-name=default>] bootstrap [<project-yml-file=deploy.yml>]"
echo -e ""
echo -e "${INFO}Quick start:${NC}"
echo -e " $0 bootstrap && $0 up"
}
checkDirectories
command=$1
shift
case "${command}" in
boot|bootstrap)
[ -f "${DEPLOY_SCRIPT}" ] && SPRYKER_SELF_SCRIPT=$0 ${DEPLOY_SCRIPT} down > /dev/null 2>&1 && sleep 2 || true
# ------------
SOURCE_DIR=${BASH_SOURCE%/*}
# ------------
PROJECT_YAML=${1:-deploy.yml}
# ------------
[ -d "${DEPLOYMENT_DIR}" ] && rm -rf "${DEPLOYMENT_DIR}"
mkdir "${DEPLOYMENT_DIR}"
DEPLOYMENT_DIR="$( cd "${DEPLOYMENT_DIR}" >/dev/null 2>&1 && pwd )"
# ------------
validateParameters
bootDeployment
[ -d "${DESTINATION_DIR}" ] && rm -rf "${DESTINATION_DIR:?}/*"
[ ! -d "${DESTINATION_DIR}" ] && mkdir "${DESTINATION_DIR}"
cp -R "${DEPLOYMENT_DIR}/." "${DESTINATION_DIR}"
rm -rf "${DEPLOYMENT_DIR}"
[ ! -f .dockerignore ] && cp "${BASH_SOURCE%/*}/.dockerignore.default" .dockerignore
echo ""
echo -e "${INFO}Deployment is generated into ${LGRAY}${DESTINATION_DIR}${NC}"
echo -e "Use ${OK}docker/sdk$([ "${PROJECT_NAME}" != 'default' ] && echo -n " -p ${PROJECT_NAME}") up${NC} to start the application."
;;
help|'')
showHelp
[ -f "${DEPLOY_SCRIPT}" ] && SPRYKER_SELF_SCRIPT=$0 ${DEPLOY_SCRIPT} help ${@}
;;
*)
[ ! -f "${DEPLOY_SCRIPT}" ] && showHelp && error "${WARN}The project is not initialized yet. Run ${YELLOW}$0 boot${WARN} before.${NC}" && exit 1
SPRYKER_SELF_SCRIPT=$0 ${DEPLOY_SCRIPT} "${command}" ${@}
;;
esac