-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_docker_image.sh
executable file
·67 lines (56 loc) · 1.82 KB
/
build_docker_image.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
#!/bin/bash -x
if [ "${1}" == "dev" ]; then
BUILDMODE="dev"
if [ -z "${ANCHORE_SRC_HOME}" ]; then
ANCHORESRCHOME="/root/"
else
ANCHORESRCHOME="${ANCHORE_SRC_HOME}"
fi
if [ -d "${ANCHORESRCHOME}/wheelhouse" ]; then
ANCHOREWHEELHOUSE="${ANCHORESRCHOME}/wheelhouse"
fi
if [ -z "${ANCHORE_ENGINE_DOCKERFILE}" ]; then
DOCKERFILE="scripts/dockerfiles/Dockerfile.dev"
else
DOCKERFILE="${ANCHORE_ENGINE_DOCKERFILE}"
fi
if [ -z "${ANCHORE_ENGINE_TAG}" ]; then
TAG="anchore-engine:dev"
else
TAG="${ANCHORE_ENGINE_TAG}"
fi
else
BUILDMODE="latest"
DOCKERFILE="Dockerfile"
TAG="anchore-engine:latest"
fi
#if [ "$1" == "use-cache" ]
#then
# echo "Building with cache usage allowed"
# cache_directive=""
#else
# echo "Building with no cache usage. To enable usage pass value 'use-cache' as param one to this script"
# cache_directive="--no-cache"
#fi
set -e
# CACHE_DIRECTIVE="--no-cache"
CACHE_DIRECTIVE=""
mkdir -p /tmp/anchore-engine-build
rm -rf /tmp/anchore-engine-build/anchore-engine/
cp -a ${DOCKERFILE} /tmp/anchore-engine-build/Dockerfile
cd /tmp/anchore-engine-build/
if [ "${BUILDMODE}" == "dev" ]; then
rsync -azP /${ANCHORESRCHOME}/anchore-engine/ /tmp/anchore-engine-build/anchore-engine/
rsync -azP /${ANCHORESRCHOME}/anchore-cli/ /tmp/anchore-engine-build/anchore-cli/
#rsync -azP /${ANCHORESRCHOME}/anchore/ /tmp/anchore-engine-build/anchore/
else
git clone git@github.com:anchore/anchore-engine.git
fi
#cd anchore-engine; export CURRHASH=`git log --pretty=format:'%H' -n 1`; cd ..
WHEELVOLUME=""
if [ ! -z "$ANCHOREWHEELHOUSE" ]; then
if [ -d "$ANCHOREWHEELHOUSE" ]; then
WHEELVOLUME="-v ${ANCHOREWHEELHOUSE}:/wheelhouse"
fi
fi
cd /tmp/anchore-engine-build && docker build -t ${TAG} ${CACHE_DIRECTIVE} ${WHEELVOLUME} . && docker tag ${TAG} anchore/${TAG}