-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·59 lines (46 loc) · 1.6 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
#!/bin/bash
set -e
if [[ $# -lt 1 ]]; then
echo "usage: ${0##*/} PROJECT"
exit 1
fi
PROJECT=${1}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. ${SCRIPT_DIR}/bamboo.conf
# Make sure we have the latest bamboo-base image
docker build \
--pull \
--file=${SCRIPT_DIR}/dockerfiles/bamboo-base/Dockerfile \
--tag=bamboo-base ${SCRIPT_DIR}/dockerfiles/bamboo-base
# Generate build image
cd ${bamboo_working_directory}
cp -rf ${SCRIPT_DIR}/dockerfiles/${PROJECT}/* .
docker build \
--file=Dockerfile \
--tag=${DOCKER_IMAGE}-builder:tmp .
IS_EXISTING=$(docker ps -qa --filter name=${DOCKER_IMAGE}-builder 2>/dev/null)
if [[ -n ${IS_EXISTING} ]]; then
docker rm --force ${DOCKER_IMAGE}-builder
fi
# Make sure volumes for instant cache and ccache exists
docker volume create --name instant-cache-${DOCKER_IMAGE_BASENAME}
docker volume create --name ccache
docker run \
--name ${DOCKER_IMAGE}-builder \
--volume ccache:/home/fenics/.ccache \
--volume ${bamboo_working_directory}:${BAMBOO_WORKDIR} \
--workdir /home/fenics \
${DOCKER_IMAGE}-builder:tmp \
build.sh
docker commit \
--author "FEniCS Bamboo" \
--message "Generated by ${bamboo_buildResultsUrl}" \
--change 'CMD ["/bin/bash", "-i"]' \
${DOCKER_IMAGE}-builder ${DOCKER_REPO}
docker rm ${DOCKER_IMAGE}-builder
docker login \
--username ${bamboo_DOCKER_REGISTRY_USERNAME} \
--email ${bamboo_DOCKER_REGISTRY_EMAIL} \
--password ${bamboo_DOCKER_REGISTRY_PASSWORD} \
${bamboo_DOCKER_REGISTRY_SERVER}
docker push ${DOCKER_REPO}