forked from puzzle/svn-docker-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (32 loc) · 1.03 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
#!/bin/bash
set -o pipefail
#IFS=$'\n\t'
DOCKER_SOCKET=/var/run/docker.sock
if [ ! -e "${DOCKER_SOCKET}" ]; then
echo "Docker socket missing at ${DOCKER_SOCKET}"
exit 1
fi
if [ -n "${OUTPUT_IMAGE}" ]; then
TAG="${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}"
fi
BUILD_DIR=$(mktemp --directory --suffix=docker-build)
pushd "${BUILD_DIR}"
if [ -e /etc/secret-volume/.subversion ]; then
cp -r /etc/secret-volume/.subversion $HOME
fi
svn checkout "${SOURCE_REPOSITORY}" .
echo -e ".d2i" >> .dockerignore
popd
if [ -x "${BUILD_DIR}/.d2i/pre_build" ]; then
"${BUILD_DIR}/.d2i/pre_build" "$BUILD_DIR" "$TAG"
fi
docker build --rm -t "${TAG}" -f "${BUILD_DIR}/${DOCKERFILE:-Dockerfile}" "${BUILD_DIR}"
if [[ -d /var/run/secrets/openshift.io/push ]] && [[ ! -e /root/.dockercfg ]]; then
cp /var/run/secrets/openshift.io/push/.dockercfg /root/.dockercfg
fi
if [ -n "${OUTPUT_IMAGE}" ] || [ -s "/root/.dockercfg" ]; then
docker push "${TAG}"
if [ -x "${BUILD_DIR}/.d2i/post_build" ]; then
"${BUILD_DIR}/.d2i/post_build" "$BUILD_DIR" "$TAG"
fi
fi