This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
build.include
119 lines (109 loc) · 3.34 KB
/
build.include
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
set -e
set -u
IMAGE_TAG="next"
THEIA_GITHUB_REPO="eclipse-theia/theia"
THEIA_VERSION="master"
THEIA_BRANCH="master"
THEIA_COMMIT_SHA="38e2ba301785ec4a08dfc27a8b23d159f489bbdf"
THEIA_GIT_REFS="refs\\/heads\\/master"
THEIA_DOCKER_IMAGE_VERSION=
SHA1_SUFFIX=
prepare_yarn_root_args() {
IFS=',' read -r -a YARN_ARGS_ARRAY <<< "$@"
for i in ${YARN_ARGS_ARRAY[@]+"${YARN_ARGS_ARRAY[@]}"}; do
YARN_OPTS+="$i "
done
}
parse() {
PUBLISH_IMAGES=false
YARN_OPTS=""
FILTERED_ARGS=""
while [ $# -gt 0 ]; do
case $1 in
--pr)
# For compatibility issue
shift ;;
--push)
PUBLISH_IMAGES=true
shift ;;
--root-yarn-opts*:*)
ROOT_YARN_CSV="${1#*:}"
prepare_yarn_root_args $ROOT_YARN_CSV
shift ;;
*)
FILTERED_ARGS="${FILTERED_ARGS} $1"
shift;;
esac
done
}
is_publish_images() {
if [[ "${PUBLISH_IMAGES}" == "true" ]]; then
return 0
else
return 1
fi
}
# KEEP RIGHT ORDER!!!
DOCKER_FILES_LOCATIONS=(
dockerfiles/theia-dev
dockerfiles/theia
dockerfiles/theia-endpoint-runtime-binary
)
PUBLISH_IMAGES_LIST=(
eclipse/che-theia-dev
eclipse/che-theia
eclipse/che-theia-endpoint-runtime-binary
)
getImages() {
echo "${DOCKER_FILES_LOCATIONS[@]}"
}
buildImages() {
IFS=" " read -r -a IMG_LIST <<< "$(getImages)"
for image_dir in "${IMG_LIST[@]}"
do
GITHUB_TOKEN_ARG="GITHUB_TOKEN=${GITHUB_TOKEN:-}"
echo "Building image in ${image_dir}"
if [ "$image_dir" == "dockerfiles/theia" ]; then
bash $(pwd)/$image_dir/build.sh --build-args:${GITHUB_TOKEN_ARG},THEIA_VERSION=${THEIA_VERSION},THEIA_COMMIT_SHA=${THEIA_COMMIT_SHA},THEIA_GITHUB_REPO=${THEIA_GITHUB_REPO} --tag:${IMAGE_TAG} --branch:${THEIA_BRANCH} --git-ref:${THEIA_GIT_REFS} ${FILTERED_ARGS}
elif [ "$image_dir" == "dockerfiles/theia-dev" ]; then
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:${IMAGE_TAG} ${FILTERED_ARGS}
else
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:${IMAGE_TAG} ${FILTERED_ARGS}
fi
if [ $? -ne 0 ]; then
echo "ERROR:"
echo "build of '$image_dir' image has failed!"
exit 1
fi
done
}
publishImages() {
REGISTRY="quay.io"
for image in "${PUBLISH_IMAGES_LIST[@]}"
do
echo "Publishing ${image}:${IMAGE_TAG}..."
docker tag "${image}:${IMAGE_TAG}" "${REGISTRY}/${image}:${IMAGE_TAG}"
echo y | docker push "${REGISTRY}/${image}:${IMAGE_TAG}"
if [[ -n "${THEIA_DOCKER_IMAGE_VERSION}" ]]; then
echo "Publishing ${image}:${THEIA_DOCKER_IMAGE_VERSION}..."
docker tag "${image}:${IMAGE_TAG}" "${REGISTRY}/${image}:${THEIA_DOCKER_IMAGE_VERSION}"
echo y | docker push "${REGISTRY}/${image}:${THEIA_DOCKER_IMAGE_VERSION}"
else
SHORT_SHA=$(git rev-parse --short HEAD)
if [[ -n "${SHA1_SUFFIX}" ]]; then
SHORT_SHA=${SHORT_SHA}-${SHA1_SUFFIX}
fi
echo "Publishing ${image}:${SHORT_SHA}..."
docker tag "${image}:${IMAGE_TAG}" "${REGISTRY}/${image}:${SHORT_SHA}"
echo y | docker push "${REGISTRY}/${image}:${SHORT_SHA}"
fi
done
}