You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/05/15 10:51:48 UTC

[servicecomb-kie] branch master updated (7834165 -> ebcea39)

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git.


    from 7834165  add rest api for put and find, (#3)
     new 849ec5e  add docker compose deployment build script for release a binary default port is 30110 upgrade go-archaius
     new ebcea39  add license

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |  1 +
 README.md                                          | 29 ++++++-
 build/build_server.sh                              | 95 ++++++++++++++++++++++
 build/docker/server/Dockerfile                     | 26 ++++++
 .../v1/doc_struct.go => deployments/docker/db.js   | 23 +++---
 deployments/docker/docker-compose.yaml             | 17 +++-
 examples/dev/REAMDME.md                            | 23 ++++--
 examples/dev/conf/chassis.yaml                     |  2 +-
 go.mod                                             |  2 +-
 scripts/start.sh                                   | 58 +++++++++++++
 10 files changed, 249 insertions(+), 27 deletions(-)
 create mode 100755 build/build_server.sh
 create mode 100644 build/docker/server/Dockerfile
 copy server/resource/v1/doc_struct.go => deployments/docker/db.js (78%)
 create mode 100755 scripts/start.sh


[servicecomb-kie] 02/02: add license

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git

commit ebcea39c60d289c77dcec0d4f654aa58b6b44e7f
Author: tian <xi...@gmail.com>
AuthorDate: Wed May 15 16:43:03 2019 +0800

    add license
---
 build/build_server.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/build/build_server.sh b/build/build_server.sh
index 63693a7..4aeeded 100755
--- a/build/build_server.sh
+++ b/build/build_server.sh
@@ -1,4 +1,19 @@
 #!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 export BUILD_DIR=$(cd "$(dirname "$0")"; pwd)
 export PROJECT_DIR=$(dirname ${BUILD_DIR})
 echo "downloading dependencies"


[servicecomb-kie] 01/02: add docker compose deployment build script for release a binary default port is 30110 upgrade go-archaius

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git

commit 849ec5edca0cbc4bcab06d0301f9901fcc54dfc9
Author: tian <xi...@gmail.com>
AuthorDate: Tue May 14 15:33:35 2019 +0800

    add docker compose deployment
    build script for release a binary
    default port is 30110
    upgrade go-archaius
---
 .gitignore                             |  1 +
 README.md                              | 29 ++++++++++--
 build/build_server.sh                  | 80 ++++++++++++++++++++++++++++++++++
 build/docker/server/Dockerfile         | 26 +++++++++++
 deployments/docker/db.js               | 29 ++++++++++++
 deployments/docker/docker-compose.yaml | 17 ++++++--
 examples/dev/REAMDME.md                | 23 ++++++----
 examples/dev/conf/chassis.yaml         |  2 +-
 go.mod                                 |  2 +-
 scripts/start.sh                       | 58 ++++++++++++++++++++++++
 10 files changed, 251 insertions(+), 16 deletions(-)

diff --git a/.gitignore b/.gitignore
index fcf40a7..8d99bb8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ vendor/**
 !vendor/manifest
 
 **/conf/servicecomb-kie/
+release
 !etc/conf/
 etc/data/
 etc/ssl/
diff --git a/README.md b/README.md
index c427b6a..21b98ae 100644
--- a/README.md
+++ b/README.md
@@ -36,11 +36,12 @@ based on template language
 - frontend: web console for kie
 
 ## Features
-
-TODO
 - simple key name with rich labels: user can define labels for a key, 
 that distinguish from key to another key.  
-a key will not be stringed by fixed schema. 
+
+TODO
+
+- a key will not be stringed by fixed schema. 
 labels for a key is like "env=test, service=cart, version=1.0" or "cluster=xxx"  
 or "env=test, service=cart, version=1.0, ip=x.x.x.x"
 - validator: value can be checked by user defined python script, 
@@ -63,10 +64,32 @@ to a distributed system in separated views.
 - kv change history: all kv changes is recorded and can be easily roll back by UI
 ## Quick Start
 
+### Run locally with Docker compose
+
+```bash
+git clone git@github.com:apache/servicecomb-kie.git
+cd servicecomb-kie/deployments/docker
+sudo docker-compose up
+```
+it will launch 3 components 
+- mongodb: 127.0.0.1:27017
+- mongodb UI:http://127.0.0.1:8081
+- servicecomb-kie: http://127.0.0.1:30110
+
 
 ## Development
 To see how to build a local dev environment, check [here](examples/dev)
 
+### Build
+```bash
+cd build
+export VERSION=0.0.1
+./build_server.sh
+```
+
+this will generate a "servicecomb-kie-0.0.1-linux-amd64.tar" in "release" folder,
+and a docker image "servicecomb/kie:0.0.1"
+
 ## Contact
 
 Bugs: [issues](https://issues.apache.org/jira/browse/SCB)
diff --git a/build/build_server.sh b/build/build_server.sh
new file mode 100755
index 0000000..63693a7
--- /dev/null
+++ b/build/build_server.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+export BUILD_DIR=$(cd "$(dirname "$0")"; pwd)
+export PROJECT_DIR=$(dirname ${BUILD_DIR})
+echo "downloading dependencies"
+cd ${PROJECT_DIR}
+GO111MODULE=on go mod vendor
+version="latest"
+release_dir=${PROJECT_DIR}/release/kie
+
+if [ -z "${VERSION}" ]; then
+ echo "missing VERSION env, use ${version} as release version"
+else
+ version=${VERSION}
+fi
+
+
+
+if [ -d ${release_dir} ]; then
+    rm -rf ${release_dir}
+fi
+
+mkdir -p ${release_dir}/conf
+pkg_name="servicecomb-kie-$version-linux-amd64.tar.gz"
+
+export GIT_COMMIT=`git rev-parse HEAD | cut -b 1-7`
+echo "build from ${GIT_COMMIT}"
+
+
+echo "building..."
+go build -o ${release_dir}/kie github.com/apache/servicecomb-kie/cmd/kie
+
+
+writeConfig(){
+echo "write template config..."
+cat <<EOM > ${release_dir}/conf/chassis.yaml
+cse:
+  service:
+    registry:
+      disabled: true
+      address: http://127.0.0.1:30100
+  protocols:
+    rest:
+      listenAddress: 127.0.0.1:30108
+    rest-consul: #consul compatible API
+      listenAddress: 127.0.0.1:8500
+  handler:
+    chain:
+      Provider:
+        default: auth-handler,ratelimiter-provider
+EOM
+
+cat <<EOM > ${release_dir}/conf/microservice.yaml
+service_description:
+  name: servicecomb-kie
+  version: ${version}
+EOM
+
+cat <<EOM > ${release_dir}/conf/kie-conf.yaml
+db:
+  uri: mongodb://admin:123@127.0.0.1:27017/kie
+  type: mongodb
+  poolSize: 10
+  ssl: false
+  sslCA:
+  sslCert:
+EOM
+}
+
+writeConfig
+
+echo "packaging tar.gz..."
+cd ${release_dir}
+tar zcf ${pkg_name} conf kie
+
+
+
+echo "building docker..."
+cp ${PROJECT_DIR}/scripts/start.sh ./
+
+sudo docker build -t servicecomb/kie:${version} -f ${PROJECT_DIR}/build/docker/server/Dockerfile .
\ No newline at end of file
diff --git a/build/docker/server/Dockerfile b/build/docker/server/Dockerfile
new file mode 100644
index 0000000..2eb34d0
--- /dev/null
+++ b/build/docker/server/Dockerfile
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM ubuntu:19.04
+
+RUN apt-get update && apt-get install -y net-tools
+RUN mkdir -p /etc/servicecomb-kie/
+RUN mkdir -p /opt/servicecomb-kie/conf
+RUN export GO_CHASSIS=/opt/servicecomb-kie
+
+ADD ./kie /opt/servicecomb-kie/
+ADD ./start.sh /opt/servicecomb-kie/
+ADD ./conf/microservice.yaml /opt/servicecomb-kie/conf/
+ENTRYPOINT ["/opt/servicecomb-kie/start.sh"]
\ No newline at end of file
diff --git a/deployments/docker/db.js b/deployments/docker/db.js
new file mode 100644
index 0000000..2f1ff7a
--- /dev/null
+++ b/deployments/docker/db.js
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+db.createUser(
+    {
+        user: "kie",
+        pwd: "123",
+        roles:[
+            {
+                role: "readWrite",
+                db:   "kie"
+            }
+        ]
+    }
+);
\ No newline at end of file
diff --git a/deployments/docker/docker-compose.yaml b/deployments/docker/docker-compose.yaml
index 700fa28..4bcbca0 100644
--- a/deployments/docker/docker-compose.yaml
+++ b/deployments/docker/docker-compose.yaml
@@ -17,14 +17,16 @@
 version: '3.1'
 services:
   mongo:
-    image: mongo
+    image: mongo:3.4
     restart: always
     ports:
       - 27017:27017
     environment:
+      MONGO_INITDB_DATABASE: kie
       MONGO_INITDB_ROOT_USERNAME: kie
       MONGO_INITDB_ROOT_PASSWORD: 123
-
+    volumes:
+      - ./db.js:/docker-entrypoint-initdb.d/db.js:ro
   mongo-express:
     image: mongo-express
     restart: always
@@ -32,4 +34,13 @@ services:
       - 8081:8081
     environment:
       ME_CONFIG_MONGODB_ADMINUSERNAME: kie
-      ME_CONFIG_MONGODB_ADMINPASSWORD: 123
\ No newline at end of file
+      ME_CONFIG_MONGODB_ADMINPASSWORD: 123
+  servicecomb-kie:
+    image: servicecomb/kie:latest
+    restart: always
+    ports:
+      - 30110:30110
+    environment:
+      MONGODB_USER: kie
+      MONGODB_PWD: 123
+      MONGODB_ADDR: mongo
\ No newline at end of file
diff --git a/examples/dev/REAMDME.md b/examples/dev/REAMDME.md
index 5b770d1..9f85df0 100644
--- a/examples/dev/REAMDME.md
+++ b/examples/dev/REAMDME.md
@@ -1,10 +1,11 @@
 # Intro
-that is a simple example to run kie in you local machine
+this guide will show you how to develop servicecomb-kie in your local machine. 
 
-you only need to set up a mongodb and config credential 
-and related info in kie-conf.yaml
+servicecomb-kie only depend on mongodb, so you have 2 choices
+- setup a mongodb and give credential in kie-conf.yaml
+- setup a simple mongodb alone with admin UI by docker compose 
 
-you can setup a simple mongodb alone with admin UI by docker compose 
+in this guide, we will use mongodb launched by docker compose
 
 # Get started
 
@@ -20,8 +21,14 @@ sudo docker-compose up
 ./kie --config kie-conf.yaml
 ```
 
-3. check service API document
-```bash
-cd examples/dev/conf/servicecomb-kie/schema
-```
+# mongodb admin UI
+http://127.0.0.1:8081/
+
+#servicecomb-kie endpoint
+http://127.0.0.1:30110/
+
+# API document
+the API doc will be generated under 
+examples/dev/conf/servicecomb-kie/schema
+
 you can copy it to https://editor.swagger.io/ to see full API document
diff --git a/examples/dev/conf/chassis.yaml b/examples/dev/conf/chassis.yaml
index d3d4c4b..c98a93b 100755
--- a/examples/dev/conf/chassis.yaml
+++ b/examples/dev/conf/chassis.yaml
@@ -6,7 +6,7 @@ cse:
       address: http://127.0.0.1:30100
   protocols:
     rest:
-      listenAddress: 127.0.0.1:30108
+      listenAddress: 127.0.0.1:30110
     rest-consul: #consul compatible API
       listenAddress: 127.0.0.1:8500
   handler:
diff --git a/go.mod b/go.mod
index 368d3a8..2161b5c 100644
--- a/go.mod
+++ b/go.mod
@@ -2,7 +2,7 @@ module github.com/apache/servicecomb-kie
 
 require (
 	github.com/emicklei/go-restful v2.8.0+incompatible
-	github.com/go-chassis/go-archaius v0.14.0
+	github.com/go-chassis/go-archaius v0.16.0
 	github.com/go-chassis/go-chassis v1.4.0
 	github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2
 	github.com/go-mesh/openlogging v1.0.1-0.20181205082104-3d418c478b2d
diff --git a/scripts/start.sh b/scripts/start.sh
new file mode 100755
index 0000000..35e62ea
--- /dev/null
+++ b/scripts/start.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
+root_dir=/opt/servicecomb-kie
+net_name=$(ip -o -4 route show to default | awk '{print $5}')
+listen_addr=$(ifconfig ${net_name} | grep -E 'inet\W' | grep -o -E [0-9]+.[0-9]+.[0-9]+.[0-9]+ | head -n 1)
+
+
+writeConfig(){
+echo "write template config..."
+cat <<EOM > ${root_dir}/conf/chassis.yaml
+cse:
+  service:
+    registry:
+      disabled: true
+  protocols:
+    rest:
+      listenAddress: ${listen_addr}:30110
+    rest-consul: #consul compatible API
+      listenAddress: ${listen_addr}:8500
+  handler:
+    chain:
+      Provider:
+        default: auth-handler,ratelimiter-provider
+EOM
+
+cat <<EOM > /etc/servicecomb-kie/kie-conf.yaml
+db:
+  uri: mongodb://${MONGODB_USER}:${MONGODB_PWD}@${MONGODB_ADDR}/kie
+  type: mongodb
+  poolSize: 10
+  ssl: false
+  sslCA:
+  sslCert:
+EOM
+}
+
+
+echo "prepare config file...."
+writeConfig
+
+echo "start kie server"
+/opt/servicecomb-kie/kie --config /etc/servicecomb-kie/kie-conf.yaml
\ No newline at end of file