-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_local_image.sh
executable file
·102 lines (70 loc) · 2.6 KB
/
build_local_image.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
source ./_common.sh
function build_docker_image {
local docker_image_name=${2}
local release_version=${3}
DOCKER_IMAGE_TAGS=()
DOCKER_IMAGE_TAGS+=(${docker_image_name}:${release_version}-${TIMESTAMP})
DOCKER_IMAGE_TAGS+=(${docker_image_name}:${release_version})
docker build \
--build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \
--build-arg LABEL_NAME="${docker_image_name}-${release_version}" \
--build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \
--build-arg LABEL_VCS_URL=$(git config --get remote.origin.url) \
--build-arg LABEL_VERSION="${release_version}" \
--build-arg APPLICATION_SERVER="${5}" \
$(get_docker_image_tags_args ${DOCKER_IMAGE_TAGS[@]}) \
${TEMP_DIR}
}
function check_usage() {
if [ ! -n "${3}" ]; then
echo "Usage: ${0} path-to-bundle image-name version [push] [application server]"
echo ""
echo "Example: "
echo -e "\t 1. Build docker image from Liferay Tomcat Bundle"
echo -e "\t\t ${0} ../bundles/master portal-snapshot demo-cbe09fb0"
echo -e "\t 2. Build docker image from Liferay Tomcat Bundle with push the image"
echo -e "\t\t ${0} ../bundles/master portal-snapshot demo-cbe09fb0 push"
echo -e "\t 3. Build docker image Liferay with JBoss EAP Bundle without push the image"
echo -e "\t\t ${0} ../../bundles/ portal-snapshot liferay72-dxp-dev no-push jboss-eap"
echo -e "\t 4. Build docker image Liferay with JBoss EAP Bundle with push the image"
echo -e "\t\t ${0} ../../bundles/ portal-snapshot liferay72-dxp-dev push jboss-eap"
exit 1
fi
check_utils curl docker java
}
function main() {
check_usage ${@}
make_temp_directory templates/bundle
if [[ ${5} == "jboss-eap" ]]; then
prepare_temp_for_manual_installation "${@}"
install_jboss_patch
prepare_jboss_eap
prepare_patching_tool "${@}"
install_fix_pack "${@}"
install_security_fix_pack "${@}"
install_hotfix "${@}"
else
prepare_temp_directory "${@}"
prepare_tomcat
fi
build_docker_image "${@}"
if [[ ${5} != "jboss-eap" ]]; then
test_docker_image
fi
push_docker_images "${4}"
clean_up_temp_directory
}
function prepare_patching_tool() {
if [ ! -e ${TEMP_DIR}/liferay/patching-tool ]; then
local patching_tool_archive_file=$(get_patching_tool_archive "${1}")
if [[ -e ${patching_tool_archive_file} ]]; then
unzip "${patching_tool_archive_file}" -d ${TEMP_DIR}/liferay/
${TEMP_DIR}/liferay/patching-tool/patching-tool.sh auto-discovery
fi
fi
}
function prepare_temp_directory() {
cp -a "${1}" "${TEMP_DIR}/liferay"
}
main "${@}"