kaspad/run-dev.sh
stasatdaglabs 88b7e7ca03 [NOD-394] Add --cleanup to ./run-dev.sh (#441)
* [NOD-394] Rename --only-build to --no-run.

* [NOD-394] Allow --rm and --no-build to be run together with no-run.

* [NOD-394] Make --cleanup alias for --rm --no-run --no-build.

* [NOD-394] Fix typo in usage string.

* [NOD-394] Set docker/docker-compose.yaml to use devnet instead of testnet.
2019-10-30 17:12:48 +02:00

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# This is a short script that compiles the code inside a docker container, and runs two instances connected to each other
# docker defenition is in docker/Dockerfile.dev
# instances defenition is in docker/docker-compose.yml
set -e
if [[ $* == *--help* ]]
then
echo "Usage:"
echo -e "\t./run-dev.sh [--rm] [--debug]"
echo ""
echo -e "\t--rm\t\tRemove dockers prior to running them, to clear data"
echo -e "\t--debug\t\tEnable debugging on second server. Server will not start until debugger is attached"
echo -e "\t--no-build\t\tRun without building docker images"
echo -e "\t--no-run\t\tBuild docker images without running"
echo -e "\t--cleanup\t\tAlias for --rm --no-run --no-build. Overrides all other flags"
exit
fi
if [[ $* == *--cleanup* ]]
then
set -- "--rm --no-run --no-build"
fi
export SERVICE_NAME=btcd
export GIT_COMMIT=$(git rev-parse --short=12 HEAD)
if [[ $* != *--no-build* ]]
then
docker build -t "${SERVICE_NAME}:${GIT_COMMIT}" . \
-f docker/Dockerfile.dev \
|| fatal 'Failed to build the docker image'
docker tag "${SERVICE_NAME}:${GIT_COMMIT}" "${SERVICE_NAME}:latest"
fi
cd docker
if [[ $* == *--rm* ]]
then
docker-compose rm -f -s -v
fi
if [[ $* != *--no-run* ]]
then
if [[ $* == *--debug* ]]
then
docker-compose up first second-debug
else
docker-compose up first second
fi
fi