-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.sh
executable file
·73 lines (66 loc) · 1.98 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
#!/bin/bash
# DOCKER_USER=dajohn BRANCH=test|prod [SKIP_PULL=1] [SKIP_BUILD=1] [SKIP_PUSH=1] [PRUNE=1] [API_REPO_PATH="$HOME/dev/LF/dev-analytics-api"] ./docker-images/build.sh
# DOCKER_USER=dajohn BRANCH=test|prod [PRUNE=1] ./docker-images/remove.sh
if [ -z "${DOCKER_USER}" ]
then
echo "$0: you need to set docker user via DOCKER_USER=username"
exit 1
fi
if [ -z "${BRANCH}" ]
then
echo "$0: you need to set dev-analytics-branch via BRANCH=test|prod"
exit 2
fi
if [ -z "${API_REPO_PATH}" ]
then
API_REPO_PATH="$HOME/dev/LF-Engineering/dev-analytics-api"
fi
if [ ! -z "$PRUNE" ]
then
docker system prune -f
fi
pass=`cat zippass.secret`
if [ -z "$pass" ]
then
echo "$0: you need to specify ZIP password in gitignored file zippass.secret"
exit 3
fi
cwd="`pwd`"
cd $API_REPO_PATH || exit 4
git checkout "$BRANCH" || exit 5
if [ -z "$SKIP_PULL" ]
then
git pull || exit 6
fi
rm -rf "$cwd/sources/data" "$cwd/sources/data.zip" || exit 7
cp -R app/services/lf/bootstrap/fixtures/ "$cwd/sources/data" || exit 8
cd "${cwd}/sources" || exit 9
git checkout "$BRANCH" || exit 16
zip data.zip -P "$pass" -r data >/dev/null || exit 10
cd .. || exit 11
if [ -z "$SKIP_BUILD" ]
then
echo "Building for branch ${BRANCH}"
if [ -z "$NO_P2O" ]
then
cp ../da-ds/uuid.py ../da-ds/gitops.py ../da-ds/detect-removed-commits.sh ./sources/ || exit 14
docker build -f ./docker-images/Dockerfile -t "${DOCKER_USER}/sync-data-sources-${BRANCH}" --build-arg BRANCH="${BRANCH}" .
bs=$?
rm -f ./sources/uuid.py ./sources/gitops.py ./sources/detect-removed-commits.sh
else
cp ../da-ds/detect-removed-commits.sh ./sources/ || exit 14
docker build -f ./docker-images/Dockerfile.nop2o -t "${DOCKER_USER}/sync-data-sources-${BRANCH}" --build-arg BRANCH="${BRANCH}" .
bs=$?
rm -f ./sources/detect-removed-commits.sh
fi
if [ ! "$bs" = "0" ]
then
exit 12
fi
fi
if [ -z "$SKIP_PUSH" ]
then
echo "Pushing"
docker push "${DOCKER_USER}/sync-data-sources-${BRANCH}" || exit 13
fi
echo 'OK'