forked from eclipse-che/che-plugin-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·90 lines (83 loc) · 2.15 KB
/
build.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
#!/bin/bash
#
# Copyright (c) 2012-2018 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
REGISTRY="quay.io"
ORGANIZATION="eclipse"
TAG="nightly"
LATEST_ONLY=false
OFFLINE=false
USAGE="
Usage: ./build.sh [OPTIONS]
Options:
--help
Print this message.
--tag, -t [TAG]
Docker image tag to be used for image; default: 'nightly'
--registry, -r [REGISTRY]
Docker registry to be used for image; default 'quay.io'
--organization, -o [ORGANIZATION]
Docker image organization to be used for image; default: 'eclipse'
--latest-only
Build registry to only contain 'latest' meta.yamls; default: 'false'
--offline
Build offline version of registry, with all extension artifacts
cached in the registry; disabled by default.
"
function print_usage() {
echo -e "$USAGE"
}
function parse_arguments() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-t|--tag)
TAG="$2"
shift; shift;
;;
-r|--registry)
REGISTRY="$2"
shift; shift;
;;
-o|--organization)
ORGANIZATION="$2"
shift; shift;
;;
--latest-only)
LATEST_ONLY=true
shift
;;
--offline)
OFFLINE=true
shift
;;
*)
print_usage
exit 0
esac
done
}
parse_arguments "$@"
IMAGE="${REGISTRY}/${ORGANIZATION}/che-plugin-registry:${TAG}"
echo -n "Building image '$IMAGE' "
if [ "$OFFLINE" = true ]; then
echo "in offline mode"
docker build \
-t "$IMAGE" \
-f ./build/dockerfiles/Dockerfile \
--build-arg LATEST_ONLY="${LATEST_ONLY}" \
--target offline-registry .
else
echo ""
docker build \
-t "$IMAGE" \
-f ./build/dockerfiles/Dockerfile \
--build-arg LATEST_ONLY="${LATEST_ONLY}" \
--target registry .
fi