This repository has been archived by the owner on May 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·60 lines (48 loc) · 1.79 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
#! /bin/bash
set -e # Exit on failure
if test -z "$1"; then
read -p "isaac-app version to build (e.g. v1.3.0 or 'master'):" VERSION_TO_DEPLOY
else
VERSION_TO_DEPLOY="$1"
fi
BUILD_DIR=/tmp/isaacDeploy
echo Building in $BUILD_DIR
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
git clone -b $VERSION_TO_DEPLOY --depth 1 https://github.com/ucam-cl-dtg/isaac-app.git
cd isaac-app
# Determine segue version to use. Honest.
if [[ $VERSION_TO_DEPLOY == v* ]]; then
SEGUE_VERSION=`grep urlPrefix\(\"/api/ < app/js/app/app.js | sed 's/.*\/api\/\([^\/]*\)\/api.*/\1/g'`
else
# Change the app src to request the API from a particular branch
if test -z "$2"; then
read -p "Override API version to target [$VERSION_TO_DEPLOY]" SEGUE_VERSION
else
SEGUE_VERSION=$2
fi
SEGUE_VERSION=${SEGUE_VERSION:-$VERSION_TO_DEPLOY}
sed -i.bak "s/api\/[^\/]*\/api/api\/$SEGUE_VERSION\/api/g" app/js/app/app.js
rm app/js/app/app.js.bak
fi
npm install
npm run build:prod
docker build -t "docker.isaacscience.org/isaac-app:${VERSION_TO_DEPLOY,,}" --pull --build-arg API_VERSION=$SEGUE_VERSION .
docker push "docker.isaacscience.org/isaac-app:${VERSION_TO_DEPLOY,,}"
cd ..
rm -rf isaac-app
git clone -b $SEGUE_VERSION --depth 1 https://github.com/ucam-cl-dtg/isaac-api.git
cd isaac-api
if [ -n "$UPDATE_API_DEPS" ]; then
docker build -f Dockerfile-base -t isaac-api-base . --pull
fi
docker build -f Dockerfile-api -t "docker.isaacscience.org/isaac-api:$SEGUE_VERSION" .
docker push "docker.isaacscience.org/isaac-api:$SEGUE_VERSION"
docker build -f Dockerfile-etl -t "docker.isaacscience.org/isaac-etl:$SEGUE_VERSION" .
docker push "docker.isaacscience.org/isaac-etl:$SEGUE_VERSION"
cd ..
rm -rf isaac-api
echo "Build complete"
echo "Now run, for example:"
echo " ./compose dev $VERSION_TO_DEPLOY up -d"