forked from eclipse-che/che-devfile-registry
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·85 lines (78 loc) · 2.22 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
#!/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
REGISTRY="quay.io"
ORGANIZATION="eclipse"
TAG="nightly"
TARGET="registry"
DOCKERFILE="./build/dockerfiles/Dockerfile"
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'
--offline
Build offline version of registry, with all sample projects
cached in the registry; disabled by default.
--rhel
Build registry using UBI images instead of 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;
;;
--offline)
TARGET="offline-registry"
shift
;;
--rhel)
DOCKERFILE="./build/dockerfiles/rhel.Dockerfile"
shift
;;
*)
print_usage
exit 0
esac
done
}
parse_arguments "$@"
IMAGE="${REGISTRY}/${ORGANIZATION}/che-devfile-registry:${TAG}"
VERSION=$(head -n 1 VERSION)
case $VERSION in
*SNAPSHOT)
echo "Snapshot version (${VERSION}) specified in $(find . -name VERSION): building nightly plugin registry."
docker build -t "${IMAGE}" -f ${DOCKERFILE} --target ${TARGET} .
;;
*)
echo "Release version specified in $(find . -name VERSION): Building plugin registry for release ${VERSION}."
docker build -t "${IMAGE}" -f ${DOCKERFILE} --target ${TARGET} --build-arg "PATCHED_IMAGES_TAG=${VERSION}" .
;;
esac