This repository has been archived by the owner on Jan 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·92 lines (79 loc) · 3.35 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
91
92
#!/bin/bash -e
# Build a Conjur OSS Google Marketplace deployer container, and then use it
# to deploy and test Conjur OSS on GKE.
function usage {
echo "Usage:"
echo " $0 [ <command line arguments> ]"
echo "Where the optional command line arguments are:"
echo " (-c | --chart-dir) <chart-directory> # Helm chart source dir"
echo " (-h | --help) # Show usage"
echo " (-p | --persist) # Keep deployment after"
echo " # testing"
echo
echo "Optional Environment Variables:"
echo " CERTIFICATE_CN: Subject Common Name to use in Conjur certificate."
echo " Defaults to 'conjur.myorg.com'."
echo " NAME: Name of Conjur Kubernetes application."
echo " Defaults to 'conjur'."
echo " NAMESPACE: Namespace to which to deploy."
echo " REGISTRY: Google cloud registry to use for Marketplace images."
echo " Defaults to 'gcr.io/conjur-cloud-launcher-onboard'."
echo " TAG: Tag to apply to Marketplace images."
echo " Defaults to contents of 'VERSION' file."
}
export NAME=${NAME:-conjur}
export NAMESPACE=${NAMESPACE:-}
export REGISTRY=${REGISTRY:-'gcr.io/conjur-cloud-launcher-onboard'}
export TAG=${TAG:-$(cat VERSION)}
# When the build_target is configured for testing (e.g. when build_target is
# "app/test"), then $CERTIFICATE_CN defines the issuer common name (CN) to
# be used in the CA certificate that is generated by Conjur. This value can
# then be used to create a DNS A record (or /etc/hosts entry) for accessing
# Conjur.
export CERTIFICATE_CN=${CERTIFICATE_CN:-'conjur.myorg.com'}
# Process command line arguments
chart_dir=""
build_target="app/verify"
while [ "$1" != "" ]; do
case $1 in
-c | --chart-dir ) shift
chart_dir="${1}"
;;
-h | --help ) usage
exit 0
;;
# Use the -p | --persist flag to keep the application running
-p | --persist ) build_target="app/install-test"
;;
* ) >&2 echo "Unknown argument: ${1}"
usage
exit 1
;;
esac
shift
done
make clean
make crd/install
gcloud auth configure-docker
if [ "${chart_dir}" != "" ]; then
if [[ ! -f "${chart_dir}/Chart.yaml" ]]; then
ls -al "${chart_dir}"
>&2 echo "ERROR: chart directory does not contain a Chart.yaml file"
exit 1
fi
echo "Chart directory specified, switching to dev mode"
mkdir -p .build
helm package -d .build --save=false "${chart_dir}"
export DOCKERFILE=deployer/Dockerfile.dev
export CONJUR_OSS_PACKAGE="$(ls .build | grep conjur-oss)"
fi
echo "Getting the desired marketplace Docker image..."
MARKETPLACE_TOOLS_TAG="0.9.10"
LOCAL_MARKETPLACE_TOOLS_TAG="local-$USER"
docker pull "gcr.io/cloud-marketplace-tools/k8s/dev:$MARKETPLACE_TOOLS_TAG"
docker tag "gcr.io/cloud-marketplace-tools/k8s/dev:$MARKETPLACE_TOOLS_TAG" \
"gcr.io/cloud-marketplace-tools/k8s/dev:$LOCAL_MARKETPLACE_TOOLS_TAG"
echo "Building $build_target app..."
export DEPLOYER_BASE_TAG="$MARKETPLACE_TOOLS_TAG"
make -j4 -e "$build_target"
echo "Done!"