forked from OneIdentity/safeguard-bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·53 lines (46 loc) · 1.46 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
#!/bin/bash
trap "exit 1" TERM
export TOP_PID=$$
if [ ! -z "$1" ]; then
Version="${1}"
DockerVersionStr="${Version}-"
fi
if [ ! -z "$2" ]; then
CommitId="${2}"
fi
if [ -z "$Version" ]; then
Version=999.999.999
fi
ScriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z "$(which docker)" ]; then
>&2 echo "You must install docker to use this build script"
fi
if [ ! -z "$(docker images -q oneidentity/safeguard-bash:${DockerVersionStr}alpine)" ]; then
echo "Cleaning up the old image: oneidentity/safeguard-bash:${DockerVersionStr}alpine ..."
docker rmi --force "oneidentity/safeguard-bash:${DockerVersionStr}alpine"
fi
echo "Building a new image: oneidentity/safeguard-bash:${DockerVersionStr}alpine ..."
docker build \
--no-cache \
--build-arg BUILD_VERSION=$Version \
--build-arg COMMIT_ID=$CommitId \
-t "oneidentity/safeguard-bash:${DockerVersionStr}alpine" \
$ScriptDir
docker tag "oneidentity/safeguard-bash:${DockerVersionStr}alpine" "oneidentity/safeguard-bash:latest"
echo "Creating zip file artifact ..."
ZipFolderName="safeguard-bash-${Version}"
ZipFileName="$ZipFolderName.zip"
if [ -f "$ZipFileName" ]; then
echo "Cleaning up the old zip: $ZipFileName ..."
rm -f $ZipFileName
fi
CurDir=`pwd`
cd $ScriptDir
mkdir $ZipFolderName
cp install-local.sh $ZipFolderName
cp -r src $ZipFolderName
cp -r samples $ZipFolderName
cp -r test $ZipFolderName
zip -r $ZipFileName $ZipFolderName
rm -rf $ZipFolderName
cd $CurDir