45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
PROJECT_PATH=$(dirname "$(pwd)")
|
|
BIN_PATH=${PROJECT_PATH}/bin
|
|
set -e
|
|
|
|
source x.sh
|
|
|
|
# $1 is arch, $2 is source code path
|
|
case $1 in
|
|
linux-amd64)
|
|
print_blue "Compile for linux/amd64"
|
|
if [ -z "$(docker image inspect golang:1.13)" ]; then
|
|
docker pull golang:1.13
|
|
else
|
|
print_blue "golang:1.13 image already exist"
|
|
fi
|
|
|
|
if [ "$(docker container ls -a | grep -c bitxhub_linux)" -ge 1 ];then
|
|
print_blue "golang:1.13 container already exist"
|
|
rm -f "${BIN_PATH}"/bitxhub_linux-amd64
|
|
docker restart bitxhub_linux
|
|
docker logs bitxhub_linux -f --tail "0"
|
|
else
|
|
docker run --name bitxhub_linux -t \
|
|
-v $2:/code/bitxhub \
|
|
-v ~/.ssh:/root/.ssh \
|
|
-v ~/.gitconfig:/root/.gitconfig \
|
|
-v $GOPATH/pkg/mod:$GOPATH/pkg/mod \
|
|
golang:1.13 \
|
|
/bin/bash -c "go env -w GO111MODULE=on &&
|
|
go env -w GOPROXY=https://goproxy.cn,direct &&
|
|
go get -u github.com/gobuffalo/packr/packr &&
|
|
cd /code/bitxhub &&
|
|
make install &&
|
|
cd internal/plugins &&
|
|
make raft &&
|
|
mkdir -p /code/bitxhub/bin &&
|
|
cp /go/bin/bitxhub /code/bitxhub/bin/bitxhub_linux-amd64"
|
|
fi
|
|
;;
|
|
*)
|
|
print_red "Other architectures are not supported yet"
|
|
;;
|
|
esac
|