Files
web/bin/deploy
2025-10-23 13:53:48 -04:00

51 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
if [ "$1" = "dev" ]; then
DEV=1
shift
else
DEV=0
fi
CHAIN_ID=${1:-11155111} # Defaults to Sepolia
PROJECT=liquidity-party
REMOTE=git.dxod.org/dexorder/dexorder
if [ "$BUILD" != "1" ] && [ "$CHAIN_ID" = "31337" ]; then
echo bin/deploy must specify a production chain ID
exit 1
fi
if [ "$BUILD" != "1" ]; then
if [ "$DEV" = "1" ]; then
TAG="dev$(date +%Y%m%d%H%M%S)"
else
DIRTY="$( git status | grep "Changes " )"
if [ "$DIRTY" != "" ]; then
echo This project has uncommited changes: deployment aborted.
exit 1
fi
TAG="$( git log --oneline | head -1 | cut -d ' ' -f 1 )"
fi
echo Deploying $TAG
else
echo Building
fi
bin/generate-contracts "$CHAIN_ID" || exit 1
npm run build || exit 1
if [ "$BUILD" != "1" ]; then
echo Deploying with tag $TAG
docker build --no-cache -f deploy/Dockerfile -t dexorder/$PROJECT:latest . || exit 1
docker tag dexorder/$PROJECT:latest dexorder/$PROJECT:$TAG
docker tag dexorder/$PROJECT:$TAG $REMOTE/$PROJECT:$TAG
docker tag $REMOTE/$PROJECT:$TAG $REMOTE/$PROJECT:latest
docker push $REMOTE/$PROJECT:$TAG
YAML=$(sed "s#image: dexorder/$PROJECT*#image: $REMOTE/$PROJECT:$TAG#" deploy/liquidity-party.k8s.yaml)
echo "$YAML" | kubectl apply -f - || echo "$YAML" "\nkubectl apply failed" && exit 1
echo "$(date)" deployed $REMOTE/$PROJECT:$TAG
else
echo "$(date)" built
fi