This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·129 lines (106 loc) · 5.16 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#! /bin/bash
set -e # Exit on failure
# Specify --force at any position in the argument list to rebuild all images regardless of whether they already exist.
if [ "$1" == "--force" ]; then
FORCE_BUILD=1
shift
fi
if test -z "$1"; then
read -p "isaac-react-app version to build (e.g. v1.3.0 or ['master']): " VERSION_TO_DEPLOY
VERSION_TO_DEPLOY=${VERSION_TO_DEPLOY:-master}
else
VERSION_TO_DEPLOY="$1"
shift
fi
if [ "$1" == "--force" ]; then
FORCE_BUILD=1
shift
fi
if [ "$2" == "--force" ]; then
FORCE_BUILD=1
fi
BUILD_DIR=/tmp/isaacAppsDeploy
echo Building Ada CS and Physics apps in $BUILD_DIR: $VERSION_TO_DEPLOY
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
git clone -b $VERSION_TO_DEPLOY --depth 1 https://github.com/isaacphysics/the-analytical-engine.git
cd the-analytical-engine
APP_COMMIT_SHA=$(git rev-parse $VERSION_TO_DEPLOY)
# Determine segue version to use. Honest.
if [[ $VERSION_TO_DEPLOY == v* ]]; then
source .env
SEGUE_VERSION=$REACT_APP_API_VERSION
else
# Change the app src to request the API from a particular branch
if test -z "$1"; then
read -p "Override API version to target [$VERSION_TO_DEPLOY]: " SEGUE_VERSION
else
SEGUE_VERSION=$1
fi
SEGUE_VERSION=${SEGUE_VERSION:-$VERSION_TO_DEPLOY}
echo "" >> .env
echo "REACT_APP_API_VERSION=$SEGUE_VERSION" >> .env
fi
set +e
docker pull "docker.isaacscience.org/isaac-ada-app:${APP_COMMIT_SHA}" >/dev/null 2>&1
PULL_FAILED=$?
set -e
if [ "${PULL_FAILED}" -ne 0 ] || [ "$FORCE_BUILD" == "1" ]; then
echo "App image not already available for commit ${APP_COMMIT_SHA}. Building."
yarn --frozen-lockfile
yarn run build-ada
yarn run build-phy
yarn run build-ada-renderer
yarn run build-phy-renderer
docker build -t "docker.isaacscience.org/isaac-ada-app:${VERSION_TO_DEPLOY}" -t "docker.isaacscience.org/isaac-ada-app:${APP_COMMIT_SHA}" --pull --build-arg API_VERSION=$SEGUE_VERSION --build-arg SUBJECT=ada .
docker build -t "docker.isaacscience.org/isaac-phy-app:${VERSION_TO_DEPLOY}" -t "docker.isaacscience.org/isaac-phy-app:${APP_COMMIT_SHA}" --pull --build-arg API_VERSION=$SEGUE_VERSION --build-arg SUBJECT=physics .
docker build -t "docker.isaacscience.org/isaac-ada-app-renderer:${VERSION_TO_DEPLOY}" -t "docker.isaacscience.org/isaac-ada-app-renderer:${APP_COMMIT_SHA}" --pull --build-arg API_VERSION=$SEGUE_VERSION --build-arg SUBJECT=ada --build-arg RENDERER_PATH=-renderer .
docker build -t "docker.isaacscience.org/isaac-phy-app-renderer:${VERSION_TO_DEPLOY}" -t "docker.isaacscience.org/isaac-phy-app-renderer:${APP_COMMIT_SHA}" --pull --build-arg API_VERSION=$SEGUE_VERSION --build-arg SUBJECT=phy --build-arg RENDERER_PATH=-renderer .
docker push "docker.isaacscience.org/isaac-ada-app:${VERSION_TO_DEPLOY}"
docker push "docker.isaacscience.org/isaac-phy-app:${VERSION_TO_DEPLOY}"
docker push "docker.isaacscience.org/isaac-ada-app-renderer:${VERSION_TO_DEPLOY}"
docker push "docker.isaacscience.org/isaac-phy-app-renderer:${VERSION_TO_DEPLOY}"
docker push "docker.isaacscience.org/isaac-ada-app:${APP_COMMIT_SHA}"
docker push "docker.isaacscience.org/isaac-phy-app:${APP_COMMIT_SHA}"
docker push "docker.isaacscience.org/isaac-ada-app-renderer:${APP_COMMIT_SHA}"
docker push "docker.isaacscience.org/isaac-phy-app-renderer:${APP_COMMIT_SHA}"
else
echo "App image already built for commit ${APP_COMMIT_SHA}. Skipping build."
docker pull "docker.isaacscience.org/isaac-ada-app:${VERSION_TO_DEPLOY}"
docker pull "docker.isaacscience.org/isaac-phy-app:${VERSION_TO_DEPLOY}"
docker pull "docker.isaacscience.org/isaac-ada-app-renderer:${VERSION_TO_DEPLOY}"
docker pull "docker.isaacscience.org/isaac-phy-app-renderer:${VERSION_TO_DEPLOY}"
fi
cd ..
rm -rf the-analytical-engine
git clone -b $SEGUE_VERSION --depth 1 https://github.com/isaacphysics/isaac-api.git
cd isaac-api
API_COMMIT_SHA=$(git rev-parse $SEGUE_VERSION)
set +e
docker pull "docker.isaacscience.org/isaac-api:$API_COMMIT_SHA" >/dev/null 2>&1
PULL_FAILED=$?
set -e
if [ "${PULL_FAILED}" -ne 0 ] || [ "$FORCE_BUILD" == "1" ] || [ -n "$UPDATE_API_DEPS" ]; then
echo "API image not already available for commit ${API_COMMIT_SHA}. Building."
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" -t "docker.isaacscience.org/isaac-api:$API_COMMIT_SHA" .
docker push "docker.isaacscience.org/isaac-api:$SEGUE_VERSION"
docker push "docker.isaacscience.org/isaac-api:$API_COMMIT_SHA"
docker build -f Dockerfile-etl -t "docker.isaacscience.org/isaac-etl:$SEGUE_VERSION" -t "docker.isaacscience.org/isaac-etl:$API_COMMIT_SHA" .
docker push "docker.isaacscience.org/isaac-etl:$SEGUE_VERSION"
docker push "docker.isaacscience.org/isaac-etl:$API_COMMIT_SHA"
else
echo "API image already built for commit ${API_COMMIT_SHA}. Skipping build."
docker pull "docker.isaacscience.org/isaac-api:$SEGUE_VERSION"
docker pull "docker.isaacscience.org/isaac-etl:$SEGUE_VERSION"
fi
cd ..
rm -rf isaac-api
echo "Build complete"
echo "Now run, for example:"
echo " ./compose phy dev $VERSION_TO_DEPLOY up -d"
echo " ./compose ada dev $VERSION_TO_DEPLOY up -d"
echo