diff --git a/Makefile b/Makefile index c269473..3612666 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,14 @@ COMMIT=$(shell git rev-parse --short HEAD) #project:game prize pusher socket #type:api srv web +.PHONY : ver +ver : + + @echo "执行环境变量" + @chmod +x ./scripts/.variables.sh && ./scripts/.variables.sh + @echo "完成环境变量" + + .PHONY : install install : diff --git a/README.md b/README.md index 2d935e0..761295d 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ 1. git >= 2.17 2. wget 3. make + 4. unzip + 5. tar - 可选部署安装(**任何一种都可以,也可直接部署二进制文件**) 1. docker >= 1.13.1 @@ -57,9 +59,11 @@ ```bash git clone https://github.com/xiaomeng79/istio-micro.git ``` + +3. 3. 安装运行环境 ```bash -cd istio-micro && sudo make install +cd istio-micro && make ver && make install ``` 4. 编译代码 diff --git a/scripts/.variables.sh b/scripts/.variables.sh old mode 100644 new mode 100755 index 09ecff9..1af6533 --- a/scripts/.variables.sh +++ b/scripts/.variables.sh @@ -9,13 +9,21 @@ TARGET=${TARGET:-'main'} #执行环境 GOPROXY=${GOPROXY:-"https://goproxy.io"} +#go mod是否开启 GO111MODULE=${GO111MODULE:-"auto"} +#GOPATH的路径 GOPATH=${GOPATH:-${HOME}/"go_path"} +#其他软件的安装目录 soft_dir=${soft_dir:-${HOME}} +#go安装的版本 go_version=${go_version:-"1.12.9"} +#protoc的版本 protoc_version=${protoc_version:-"3.6.1"} +#protoc引用的路径 protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"} +#cloc版本 cloc_version=${cloc_version:-"1.76"} +#执行文件路径 cmd_path=${cmd_path:-"${GOPATH}/bin"} #将环境变量存入本地环境配置 @@ -25,4 +33,5 @@ echo "GO111MODULE=${GO111MODULE}" >>${HOME}/.profile echo "GOPATH=${GOPATH}" >>${HOME}/.profile echo "PATH=${soft_dir}/go/bin:${GOPATH}/bin:${PATH}" >>${HOME}/.profile -source ${HOME}/.profile \ No newline at end of file +#手动执行 +#source ~/.profile \ No newline at end of file diff --git a/scripts/INSTALL.md b/scripts/INSTALL.md new file mode 100644 index 0000000..828dfcd --- /dev/null +++ b/scripts/INSTALL.md @@ -0,0 +1,34 @@ +## 安装依赖 + +#### 配置环境变量 + +GOPROXY=${GOPROXY:-"https://goproxy.io"} +GO111MODULE=${GO111MODULE:-"auto"} +GOPATH=${GOPATH:-${HOME}/"go_path"} +soft_dir=${soft_dir:-${HOME}} +go_version=${go_version:-"1.12.9"} +protoc_version=${protoc_version:-"3.6.1"} +protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"} +cloc_version=${cloc_version:-"1.76"} +cmd_path=${cmd_path:-"${GOPATH}/bin"} + +```bash +echo "GOPROXY=https://goproxy.io" >>${HOME}/.profile +echo "protoc_include_path=${HOME}/protoc/include" >>${HOME}/.profile +echo "GO111MODULE=auto" >>${HOME}/.profile +echo "GOPATH=${HOME}/go_path" >>${HOME}/.profile +echo "PATH=${soft_dir}/go/bin:${GOPATH}/bin:${PATH}" >>${HOME}/.profile +``` + +#### 安装系统依赖 +```bash + 1. git >= 2.17 + 2. wget + 3. make + 4. unzip + 5. tar +``` +#### 安装go程序 +```bash + +``` \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index 62275ce..558d4d4 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -8,7 +8,7 @@ GOPROXY=${GOPROXY:-"https://goproxy.io"} soft_dir=${HOME:-"/tmp"} go_version=${go_version:-"1.11"} protoc_version=${protoc_version:-"3.6.1"} -protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-osx-x86_64/include"} +protoc_include_path=${protoc_include_path:-"${soft_dir}/protoc-${protoc_version}-linux-x86_64/include"} cloc_version=${cloc_version:-"1.76"} GOPATH=${GOPATH:-${HOME}"/go_path"} cmd_path=${cmd_path:-"${GOPATH}/bin"} @@ -16,36 +16,32 @@ cmd_path=${cmd_path:-"${GOPATH}/bin"} #go go_install(){ - hash go 2>/dev/null || ` echo "安装golang环境 go"${go_version} && \ mkdir -p ${soft_dir} && cd ${soft_dir} && \ wget -c https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz && \ tar -xzvf go${go_version}.linux-amd64.tar.gz && \ - go version ` + go version } #圈复杂分析 cloc_install(){ #安装cloc - hash cloc 2>/dev/null || ` echo "安装代码统计工具 cloc" && \ mkdir -p ${soft_dir} && cd ${soft_dir} && \ wget -c https://github.com/AlDanial/cloc/archive/v${cloc_version}.zip && \ unzip v${cloc_version}.zip && \ cp ${soft_dir}/cloc-${cloc_version}/cloc ${cmd_path}/cloc || { echo "cloc文件已经存在"; } && \ - echo "cloc 的版本是:" && cloc --version ` + echo "cloc 的版本是:" && cloc --version } protoc_install(){ - hash protoc 2>/dev/null || ` echo "安装protobuf工具 " && \ mkdir -p ${soft_dir} && cd ${soft_dir} && \ wget -c https://github.com/protocolbuffers/protobuf/releases/download/v${protoc_version}/protoc-${protoc_version}-linux-x86_64.zip && \ unzip protoc-${protoc_version}-linux-x86_64.zip -d ./protoc-${protoc_version}-linux-x86_64 && \ mv ${soft_dir}/protoc-${protoc_version}-linux-x86_64/bin/protoc ${cmd_path} && \ - echo "路径为:"${cmd_path} && \ - echo "protoc 的版本是:" && ${cmd_path}/protoc --version` + echo "protoc 的版本是:" && protoc --version } go_plug(){ @@ -53,9 +49,9 @@ go_plug(){ echo "安装 protobuf golang插件 protoc-gen-go protoc-gen-grpc-gateway protoc-gen-swagger protoc-go-inject-tag" echo "大概耗时30分钟" go get github.com/golang/protobuf/proto - go get -u github.com/golang/protobuf/protoc-gen-go - go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway - go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger + go get github.com/golang/protobuf/protoc-gen-go + go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway + go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger go get github.com/favadi/protoc-go-inject-tag echo "安装gocyclo圈复杂度计算工具" go get github.com/fzipp/gocyclo