Skip to content

Commit

Permalink
Add dev cli dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed May 5, 2020
1 parent 6ac069e commit 6025ee5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CONTRIBUTING.md
schema1.svg
.github

/scripts
/examples

# test & debug files
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.cli.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG from
FROM $from

COPY ./dev-chain/cli /root/.mesg-cli
COPY ./dev-chain/validator /root/.mesg-node
COPY ./scripts/dev-cli.sh .

CMD ["bash", "dev-cli.sh"]
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build build-cmd-cosmos changelog check-version clean clean-build clean-docker dep dev dev-mon dev-start dev-stop docker-build docker-dev docker-publish docker-publish-dev docker-tools genesis lint protobuf test publish-cmds build-docker-cli
.PHONY: all build build-cmd-cosmos changelog check-version clean clean-build clean-docker dep dev dev-mon dev-start dev-stop docker-build docker-dev docker-publish docker-publish-dev docker-tools genesis lint protobuf test publish-cmds build-docker-cli build-docker-cli-dev

MAJOR_VERSION := $(shell echo $(version) | cut -d . -f 1)
MINOR_VERSION := $(shell echo $(version) | cut -d . -f 1-2)
Expand Down Expand Up @@ -64,6 +64,9 @@ build-cmd: dep
build-docker-cli: check-version
docker build -t mesg/engine:cli -f ./Dockerfile.cli --build-arg version=$(version) .

build-docker-cli-dev: build-docker-cli
docker build -t mesg/engine:cli-dev -f ./Dockerfile.cli.dev --build-arg from=mesg/engine:cli .

e2e: docker-dev
./scripts/run-e2e.sh

Expand Down
50 changes: 50 additions & 0 deletions scripts/dev-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# turn on bash's job control
set -m

# start daemon
mesg-daemon start &
daemon=$!

# wait 5 sec for the daemon to start rpc server
sleep 5 &
wait $!

# start lcd
mesg-cli rest-server --laddr tcp://0.0.0.0:1317 &
lcd=$!

# start orchestrator
mesg-cli orchestrator start &
orchestrator=$!

# this variable is used to control the monitoring of the child process
monitoring=true

# function that stop child processes
function stop {
monitoring=false
echo "stopping all child processes"
kill $daemon $lcd $orchestrator
wait $daemon $lcd $orchestrator
}

# trap both sigint (ctrl+c) and sigterm (OS ask process to be stopped)
trap stop SIGINT
trap stop SIGTERM

# start the monitoring loop
while $monitoring
do
# check if all sub processes are running correctly
if [[ -n "$(ps -p $daemon -o pid=)" ]] && [[ -n "$(ps -p $lcd -o pid=)" ]] && [[ -n "$(ps -p $orchestrator -o pid=)" ]]; then
sleep 2 &
wait $!
else
# if one child process is not running, stopping all of them and exit with error code 1
echo "one child process is not running"
stop
exit 1
fi
done

0 comments on commit 6025ee5

Please sign in to comment.