forked from eclipse-che/che-theia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_push_docker_images.sh
executable file
·77 lines (70 loc) · 2.51 KB
/
build_and_push_docker_images.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
#!/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
#
# See: https://sipb.mit.edu/doc/safe-shell/
set -e
set -o pipefail
# KEEP RIGHT ORDER!!!
DOCKER_FILES_LOCATIONS=(
dockerfiles/theia-dev
dockerfiles/theia
dockerfiles/theia-endpoint-runtime
dockerfiles/remote-plugin-runner-java8
dockerfiles/remote-plugin-go-1.10.7
dockerfiles/remote-plugin-python-3.7.2
dockerfiles/remote-plugin-kubernetes-tooling-0.1.17
dockerfiles/remote-plugin-openshift-connector-0.0.17
)
IMAGES_LIST=(
eclipse/che-theia-dev
eclipse/che-theia
eclipse/che-theia-endpoint-runtime
eclipse/che-remote-plugin-runner-java8
eclipse/che-remote-plugin-go-1.10.7
eclipse/che-remote-plugin-python-3.7.2
eclipse/che-remote-plugin-kubernetes-tooling-0.1.17
eclipse/che-remote-plugin-openshift-connector-0.0.17
)
# BUILD IMAGES
for image_dir in "${DOCKER_FILES_LOCATIONS[@]}"
do
GITHUB_TOKEN_ARG="GITHUB_TOKEN="${GITHUB_TOKEN}
if [ "$image_dir" == "dockerfiles/theia" ]; then
THEIA_IMAGE_TAG="next"
bash $(pwd)/$image_dir/build.sh --build-args:${GITHUB_TOKEN_ARG},THEIA_VERSION=master --tag:next --branch:master --git-ref:refs\\/heads\\/master
elif [ "$image_dir" == "dockerfiles/theia-dev" ]; then
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:next
else
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:next
fi
if [ $? -ne 0 ]; then
echo "ERROR:"
echo "build of '$image_dir' image is failed!"
exit 1
fi
done
if [ "$BUILD_BRANCH" == "master" ]; then
#PUSH IMAGES
#docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
for image in "${IMAGES_LIST[@]}"
do
if [ "$image" == "eclipse/che-theia" ]; then
docker tag ${image}:next ${image}:${THEIA_IMAGE_TAG}
echo y | docker push ${image}:${THEIA_IMAGE_TAG}
elif [ "$image" == "eclipse/che-theia-dev" ]; then
docker tag ${image}:next ${image}:${THEIA_IMAGE_TAG}
echo y | docker push ${image}:${THEIA_IMAGE_TAG}
else
echo y | docker push ${image}:next
fi
done
else
echo "Skip push docker images.";
fi