Skip to content

Commit

Permalink
Merge pull request #1002 from mesg-foundation/feature/rename-engine-2
Browse files Browse the repository at this point in the history
Fix dev-core command
  • Loading branch information
antho1404 authored May 30, 2019
2 parents 175c653 + 3f9daf0 commit 1f0f8d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates=20180409 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY ./bin/core .
CMD [ "./core" ]
COPY ./bin/engine .
CMD [ "./engine" ]
41 changes: 21 additions & 20 deletions dev-core
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ LDFLAGS+=" -X 'github.com/mesg-foundation/core/config.EnvMarketplaceAddress=0xeC
LDFLAGS+=" -X 'github.com/mesg-foundation/core/config.EnvMarketplaceToken=0x5861b3dc52339d4f976b7fa5d80db6cd6f477f1b'"
MESG_SERVICE_SERVER="core-service-server"

networkExists=$(docker network list -f name=engine -f driver=overlay -q)
if [ "$networkExists" == "" ]; then
docker network create --driver overlay engine --label com.docker.stack.namespace=engine
fi

function deleteServiceServer {
rm -rf tmp-systemservices
if docker service list | grep -q core-service-server; then
Expand Down Expand Up @@ -41,22 +46,22 @@ docker service create -d \
--network engine \
$MESG_SERVICE_SERVER

echo "compile core"
GOOS=linux GOARCH=amd64 go build -o ./bin/core -ldflags="$LDFLAGS" core/main.go
echo "compile engine"
GOOS=linux GOARCH=amd64 go build -o ./bin/engine -ldflags="$LDFLAGS" core/main.go

CORE_SUM_PATH="./bin/.core.sum"
touch "$CORE_SUM_PATH"
ENGINE_SUM_PATH="./bin/.engine.sum"
touch "$ENGINE_SUM_PATH"

DOCKER_SUM_PATH="./bin/.Dockerfile.dev.sum"
touch "$DOCKER_SUM_PATH"

# check if core bin was cached
CORE_SUM="$(openssl md5 ./bin/core)"
CORE_SUM_PREV="$(cat $CORE_SUM_PATH)"
if [[ "$CORE_SUM" == "$CORE_SUM_PREV" ]]; then
# check if engine bin was cached
ENGINE_SUM="$(openssl md5 ./bin/engine)"
ENGINE_SUM_PREV="$(cat $ENGINE_SUM_PATH)"
if [[ "$ENGINE_SUM" == "$ENGINE_SUM_PREV" ]]; then
BINCACHED=true
else
echo "$CORE_SUM" > "$CORE_SUM_PATH"
echo "$ENGINE_SUM" > "$ENGINE_SUM_PATH"
fi

# check if dockerfile was cached
Expand All @@ -76,25 +81,21 @@ if [[ ! $BINCACHED ]] || [[ ! $DOCKERCACHED ]]; then
docker build -f Dockerfile.dev -t "mesg/engine:$VERSION" .
fi

# docker service rm core
# docker service rm engine

trap onexit EXIT INT

function onexit {
deleteServiceServer
docker service rm core
docker service rm engine
}

networkExists=$(docker network list -f name=^core$ -f driver=overlay -q)
if [ "$networkExists" == "" ]; then
docker network create --driver overlay core --label com.docker.stack.namespace=core
fi
docker service create \
--name core \
--name engine \
--tty \
--label com.docker.stack.namespace=core --label com.docker.stack.image=mesg/core:$VERSION \
--label com.docker.stack.namespace=engine --label com.docker.stack.image=mesg/engine:$VERSION \
--mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock --mount type=bind,source=$HOME/.mesg,destination=/mesg \
--network core --publish 50052:50052 \
mesg/core:$VERSION
--network engine --publish 50052:50052 \
mesg/engine:$VERSION

docker service logs --follow --raw core
docker service logs --follow --raw engine

0 comments on commit 1f0f8d9

Please sign in to comment.