forked from hyperledger-labs/fablo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fablo-build.sh
executable file
·37 lines (28 loc) · 913 Bytes
/
fablo-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
#!/usr/bin/env bash
set -euo
FABLO_HOME="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=2002
FABLO_VERSION=$(cat "$FABLO_HOME"/package.json | jq -r '.version')
COMMIT_HASH=$(git rev-parse --short HEAD)
BUILD_DATE=$(date +'%Y-%m-%d-%H:%M:%S')
VERSION_DETAILS="$BUILD_DATE-$COMMIT_HASH"
echo "Building new image..."
echo " FABLO_HOME: $FABLO_HOME"
echo " FABLO_VERSION: $FABLO_VERSION"
echo " VERSION_DETAILS: $VERSION_DETAILS"
IMAGE_BASE_NAME="softwaremill/fablo:$FABLO_VERSION"
if [ "$(command -v nvm)" != "nvm" ] && [ -f ~/.nvm/nvm.sh ]; then
set +e
# shellcheck disable=SC2039
source ~/.nvm/nvm.sh
set -e
fi
if [ "$(command -v nvm)" = "nvm" ]; then
nvm install
fi
npm install --silent
npm run build:dist
docker build \
--build-arg VERSION_DETAILS="$VERSION_DETAILS" \
--tag "$IMAGE_BASE_NAME" "$FABLO_HOME"
docker tag "$IMAGE_BASE_NAME" "softwaremill/fablo:$FABLO_VERSION"