-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathbuild_local_image.sh
executable file
·104 lines (80 loc) · 2.61 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
103
104
#!/bin/bash
source ./_common.sh
function build_docker_image {
local docker_image_name=${2}
local release_version=${3}
DOCKER_IMAGE_TAGS=()
DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}${docker_image_name}:${release_version}-${TIMESTAMP}")
DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}${docker_image_name}:${release_version}")
if [[ " ${@} " =~ " --push " ]]
then
LIFERAY_DOCKER_IMAGE_PLATFORMS=linux/amd64,linux/arm64
check_docker_buildx
docker buildx 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}" \
--builder "liferay-buildkit" \
--platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \
--push \
$(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \
"${TEMP_DIR}"
exit $?
fi
remove_temp_dockerfile_target_platform
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}" \
$(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 --no-warm-up --no-test-image --push"
echo ""
echo "Example: ${0} ../bundles/master portal-snapshot demo-cbe09fb0 --no-warm-up --no-test-image"
exit 1
fi
check_utils curl docker java rsync
}
function main {
check_usage "${@}"
make_temp_directory templates/bundle
prepare_temp_directory "${@}"
prepare_tomcat "${@}"
build_docker_image "${@}"
test_docker_image "${@}"
clean_up_temp_directory
}
function prepare_temp_directory {
local excludes=(
"--exclude" "*.zip"
"--exclude" "data/elasticsearch*"
"--exclude" "deploy"
"--exclude" "logs/*"
"--exclude" "osgi/state"
"--exclude" "portal-ext.properties"
"--exclude" "portal-setup-wizard.properties"
"--exclude" "tmp"
)
if [[ " ${@} " =~ " --no-test " ]]
then
excludes+=(
"--exclude" "osgi/modules/*.test*"
"--exclude" "osgi/modules/com.liferay.data.guard.connector.jar"
"--exclude" "osgi/portal/*.test*"
"--exclude" "osgi/test"
"--exclude" "osgi/war/com.liferay.portal.bundle.blacklist.test.bundle.war.war"
)
fi
rsync -aq \
"${excludes[@]}" \
"${1}/" "${TEMP_DIR}/liferay"
}
main "${@}"