You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2020/10/23 02:22:33 UTC
[apisix-dashboard] branch master updated: chore: deployment update
and remove all files related to MySQL (#581)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new bb70b1a chore: deployment update and remove all files related to MySQL (#581)
bb70b1a is described below
commit bb70b1a5d4287eb3c17c6c8fd077c2572188d255
Author: nic-chen <33...@users.noreply.github.com>
AuthorDate: Fri Oct 23 10:22:21 2020 +0800
chore: deployment update and remove all files related to MySQL (#581)
* update build/run and README
* feat: update dockerfile and compose
* chore: update README
* fix: CI failed
* chore: change go version
* fix doc style
* fix run error
* fix: update README about ETCD
---
README.md | 34 +++++++++------
README.zh-CN.md | 33 ++++++++------
api/Dockerfile | 8 ++--
api/conf/conf.go | 43 ------------------
api/conf/conf.json | 13 ------
api/conf/conf_preview.json | 13 ------
compose/manager_conf/build.sh => api/entry.sh | 30 ++++++-------
api/run.sh | 63 +++++++++++++++++++++++++++
api/run/run.sh | 54 -----------------------
compose/docker-compose.yml | 17 +-------
api/build.sh => compose/manager_conf/entry.sh | 28 +++++++-----
manager-api.md | 36 ---------------
12 files changed, 139 insertions(+), 233 deletions(-)
diff --git a/README.md b/README.md
index f919cfc..745be50 100644
--- a/README.md
+++ b/README.md
@@ -49,36 +49,42 @@ $ cd apisix-dashboard
The `manager-api` is used to provide APIs for Dashboard, just like a bridge between the Apache APISIX and the Dashboard. Here are the steps to build it manually:
-1. We need `MySQL/Golang` to be preinstalled.
+1. We need `Go` 1.13+ and `Lua` 5.1+ to be preinstalled.
+
+2. Check environment variables
+
+- enable Go MODULE
```sh
-# e.g Initialization for MySQL, please use a more secure Password instead of 123456.
-$ mysql –uroot –p123456
-> source ./api/script/db/schema.sql
+$ go env -w GO111MODULE=on
```
-2. Start the Apache APISIX.
-
-[Please follow this guide](https://github.com/apache/apisix#configure-and-installation)
+- According to your local deployment environment, check the environment variables in `./api/run.sh`, modify the environment variables if needed.
+For example, change the ETCD endpoints to your ETCD instances work with APISIX:
-3. Check environment variables
+```
+export APIX_ETCD_ENDPOINTS="127.0.0.1:2379"
+```
-According to your local deployment environment, check the environment variables in `./api/run/run.sh`, modify the environment variables if needed.
+If you have multiple instances, please use commas to separate:
-For most users in China, we could use [Goproxy](https://goproxy.cn/) to speed up downloading modules.
+```
+export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379"
+```
-4. Build
+- For most users in China, we could use [Goproxy](https://goproxy.cn/) to speed up downloading modules.
```sh
-$ cd api && go build -o ../manager-api . && cd ..
+$ go env -w GOPROXY=https://goproxy.cn,direct
```
-5. Run
+3. Build and Run
```sh
-$ sh ./api/run/run.sh &
+$ ./api/run.sh &
```
+
### Build the Dashboard
This project is initialized with [Ant Design Pro](https://pro.ant.design). The following are some quick guides for how to use.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 443b12e..7772595 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -49,34 +49,39 @@ $ cd apisix-dashboard
`manager-api` 用于为仪表盘提供接口,就像 Apache APISIX 和仪表盘之间的桥梁。下面是手动构建步骤:
-1. 需要预先安装 `MySQL/Golang`。
+1. 需要预先安装 `Go` 1.13+ 、`Lua` 5.1+
+
+2. 检查环境变量
+
+- 开启 Go MODULE
```sh
-# 例如:初始化时,推荐使用更加安全的密码,而不是 123456
-$ mysql –uroot –p123456
-> source ./api/script/db/schema.sql
+$ go env -w GO111MODULE=on
```
-2. 启动 Apache APISIX
+- 根据您的本地部署环境,检查 `./api/run.sh` 中的环境变量,如果需要请修改环境变量。
+例如, 把 ETCD 地址改为你的与 APISIX 一起工作的 ETCD 实例:
-[请参考这份指南](https://github.com/apache/apisix#configure-and-installation)
-
-3. 检查环境变量
+```
+export APIX_ETCD_ENDPOINTS="127.0.0.1:2379"
+```
-根据您的本地部署环境,检查 `./api/run/run.sh` 中的环境变量,如果需要请修改环境变量。
+如果有多个实例,请使用英文逗号分隔,如:
-对于大多数中国用户,我们可以使用 [Goproxy](https://goproxy.cn/) 加快模块下载速度。
+```
+export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379"
+```
-4. 构建
+- 对于大多数中国用户,我们可以使用 [Goproxy](https://goproxy.cn/) 加快模块下载速度。
```sh
-$ cd api && go build -o ../manager-api . && cd ..
+$ go env -w GOPROXY=https://goproxy.cn,direct
```
-5. 启动
+3. 构建并启动
```sh
-$ sh ./api/run/run.sh &
+$ ./api/run.sh &
```
### 构建仪表盘
diff --git a/api/Dockerfile b/api/Dockerfile
index 5b5d627..1af2ba0 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -24,7 +24,7 @@ RUN mkdir -p /go/manager-api \
&& go env -w GOPROXY=https://goproxy.io,direct \
&& export GOPROXY=https://goproxy.io \
&& go build -o /go/manager-api/manager-api \
- && mv /go/src/github.com/apisix/manager-api/build.sh /go/manager-api/ \
+ && mv /go/src/github.com/apisix/manager-api/entry.sh /go/manager-api/ \
&& mv /go/src/github.com/apisix/manager-api/build-tools/* /go/manager-api/build-tools/ \
&& mv /go/src/github.com/apisix/manager-api/conf/conf_preview.json /go/manager-api/conf.json \
&& rm -rf /go/src/github.com/apisix/manager-api \
@@ -66,5 +66,7 @@ RUN cd /go/manager-api/build-tools \
&& rm -rf /go/manager-api/build-tools/
EXPOSE 8080
-RUN chmod +x ./build.sh
-CMD ["/bin/ash", "-c", "/go/manager-api/build.sh"]
+
+RUN chmod +x ./entry.sh
+
+CMD ["/bin/ash", "-c", "/go/manager-api/entry.sh"]
diff --git a/api/conf/conf.go b/api/conf/conf.go
index 618274f..328cddc 100644
--- a/api/conf/conf.go
+++ b/api/conf/conf.go
@@ -41,15 +41,11 @@ var (
ENV string
basePath string
Schema gjson.Result
- ApiKey = "edd1c9f034335f136f87ad84b625c8f1"
- BaseUrl = "http://127.0.0.1:9080/apisix/admin"
DagLibPath = "/go/manager-api/dag-to-lua/"
)
func init() {
setEnvironment()
- initMysql()
- initApisix()
initAuthentication()
initSchema()
}
@@ -84,16 +80,6 @@ func getSchemaPath() string {
}
}
-type mysqlConfig struct {
- Address string
- User string
- Password string
-
- MaxConns int
- MaxIdleConns int
- MaxLifeTime int
-}
-
type user struct {
Username string
Password string
@@ -108,37 +94,8 @@ type authenticationConfig struct {
var UserList = make(map[string]user, 1)
-var MysqlConfig mysqlConfig
var AuthenticationConfig authenticationConfig
-func initMysql() {
- filePath := configurationPath()
- if configurationContent, err := ioutil.ReadFile(filePath); err != nil {
- panic(fmt.Sprintf("fail to read configuration: %s", filePath))
- } else {
- configuration := gjson.ParseBytes(configurationContent)
- mysqlConf := configuration.Get("conf.mysql")
- MysqlConfig.Address = mysqlConf.Get("address").String()
- MysqlConfig.User = mysqlConf.Get("user").String()
- MysqlConfig.Password = mysqlConf.Get("password").String()
- MysqlConfig.MaxConns = int(mysqlConf.Get("maxConns").Int())
- MysqlConfig.MaxIdleConns = int(mysqlConf.Get("maxIdleConns").Int())
- MysqlConfig.MaxLifeTime = int(mysqlConf.Get("maxLifeTime").Int())
- }
-}
-
-func initApisix() {
- filePath := configurationPath()
- if configurationContent, err := ioutil.ReadFile(filePath); err != nil {
- panic(fmt.Sprintf("fail to read configuration: %s", filePath))
- } else {
- configuration := gjson.ParseBytes(configurationContent)
- apisixConf := configuration.Get("conf.apisix")
- BaseUrl = apisixConf.Get("base_url").String()
- ApiKey = apisixConf.Get("api_key").String()
- }
-}
-
func initAuthentication() {
filePath := configurationPath()
configurationContent, err := ioutil.ReadFile(filePath)
diff --git a/api/conf/conf.json b/api/conf/conf.json
index 095f5f5..d00c492 100644
--- a/api/conf/conf.json
+++ b/api/conf/conf.json
@@ -1,20 +1,7 @@
{
"conf": {
- "mysql": {
- "address": "127.0.0.1:3306",
- "user": "root",
- "password": "123456",
- "maxConns": 50,
- "maxIdleConns": 25,
- "maxLifeTime": 10
- },
"syslog": {
"host": "127.0.0.1"
- },
- "apisix": {
- "base_url": "http://127.0.0.1:9080/apisix/admin",
- "api_key": "edd1c9f034335f136f87ad84b625c8f1",
- "debug_url": "http://127.0.0.1:9080/"
}
},
"authentication": {
diff --git a/api/conf/conf_preview.json b/api/conf/conf_preview.json
index e4df55c..eef8683 100644
--- a/api/conf/conf_preview.json
+++ b/api/conf/conf_preview.json
@@ -1,20 +1,7 @@
{
"conf": {
- "mysql": {
- "address": "#mysqlAddress#",
- "user": "#mysqlUser#",
- "password": "#mysqlPWD#",
- "maxConns": 50,
- "maxIdleConns": 25,
- "maxLifeTime": 10
- },
"syslog": {
"host": "#syslogAddress#"
- },
- "apisix": {
- "base_url": "#apisixBaseUrl#",
- "api_key": "#apisixApiKey#",
- "debug_url": "#apisixDebugUrl#"
}
},
"authentication": {
diff --git a/compose/manager_conf/build.sh b/api/entry.sh
similarity index 52%
rename from compose/manager_conf/build.sh
rename to api/entry.sh
index 8591e7f..8f7afbd 100755
--- a/compose/manager_conf/build.sh
+++ b/api/entry.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -15,25 +16,22 @@
# limitations under the License.
#
-#!/bin/sh
-
pwd=`pwd`
-export MYSQL_SERVER_ADDRESS="192.17.5.14:3306"
-export MYSQL_USER=root
-export MYSQL_PASSWORD=123456
+# config
+cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json
+
+# export APIX_DAG_LIB_PATH="${pwd}/dag-to-lua-1.1/lib/"
+# export APIX_ETCD_ENDPOINTS="127.0.0.1:2379"
+
export SYSLOG_HOST=127.0.0.1
-export APISIX_BASE_URL="http://192.17.5.11:9080/apisix/admin"
-export APISIX_API_KEY="edd1c9f034335f136f87ad84b625c8f1"
-export APISIX_DEBUG_URL="http://127.0.0.1:9080/"
-sed -i -e "s%#mysqlAddress#%`echo $MYSQL_SERVER_ADDRESS`%g" ${pwd}/conf.json
-sed -i -e "s%#mysqlUser#%`echo $MYSQL_USER`%g" ${pwd}/conf.json
-sed -i -e "s%#mysqlPWD#%`echo $MYSQL_PASSWORD`%g" ${pwd}/conf.json
-sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixBaseUrl#%`echo $APISIX_BASE_URL`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixApiKey#%`echo $APISIX_API_KEY`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixDebugUrl#%`echo $APISIX_DEBUG_URL`%g" ${pwd}/conf.json
+if [[ "$unamestr" == 'Darwin' ]]; then
+ sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+else
+ sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+fi
+
+cp ${pwd}/conf.json ${pwd}/api/conf/conf.json
-cd /go/manager-api
exec ./manager-api
diff --git a/api/run.sh b/api/run.sh
new file mode 100755
index 0000000..737cd24
--- /dev/null
+++ b/api/run.sh
@@ -0,0 +1,63 @@
+#!/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 ENV=local
+pwd=`pwd`
+
+# config
+cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json
+export APIX_DAG_LIB_PATH="${pwd}/dag-to-lua-1.1/lib/"
+export APIX_ETCD_ENDPOINTS="127.0.0.1:2379"
+export SYSLOG_HOST=127.0.0.1
+
+if [[ "$unamestr" == 'Darwin' ]]; then
+ sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+else
+ sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+fi
+
+cp ${pwd}/conf.json ${pwd}/api/conf/conf.json
+
+
+# get dag-to-lua lib
+if [[ ! -f "dag-to-lua-1.1/lib/dag-to-lua.lua" ]]; then
+ wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz
+ tar -zxvf v1.1.tar.gz
+fi
+
+
+# generate json schema
+if [[ ! -f "${pwd}/schema.json" ]]; then
+ rm master.zip
+ rm -rf ./api/build-tools/apisix/
+ wget https://github.com/apache/apisix/archive/master.zip
+ unzip master.zip
+ mkdir -p ./api/build-tools/apisix/
+ mv ./apisix-master/apisix/* ./api/build-tools/apisix/
+ rm -rf ./apisix-master
+ cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/schema.json
+ cd ../../
+fi
+
+# build
+if [[ ! -f "${pwd}/manager-api" ]]; then
+ cd ./api && go build -o ../manager-api .
+ cd ../
+fi
+
+exec ./manager-api
diff --git a/api/run/run.sh b/api/run/run.sh
deleted file mode 100755
index 00ef9b1..0000000
--- a/api/run/run.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-pwd=`pwd`
-
-cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json
-
-export MYSQL_SERVER_ADDRESS="127.0.0.1:3306"
-export MYSQL_USER=root
-export MYSQL_PASSWORD=123456
-export SYSLOG_HOST=127.0.0.1
-export APISIX_BASE_URL="http://127.0.0.1:9080/apisix/admin"
-export APISIX_API_KEY="edd1c9f034335f136f87ad84b625c8f1"
-export APISIX_DEBUG_URL="http://127.0.0.1:9080/"
-
-
-if [[ "$unamestr" == 'Darwin' ]]; then
- sed -i '' -e "s%#mysqlAddress#%`echo $MYSQL_SERVER_ADDRESS`%g" ${pwd}/conf.json
- sed -i '' -e "s%#mysqlUser#%`echo $MYSQL_USER`%g" ${pwd}/conf.json
- sed -i '' -e "s%#mysqlPWD#%`echo $MYSQL_PASSWORD`%g" ${pwd}/conf.json
- sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
- sed -i '' -e "s%#apisixBaseUrl#%`echo $APISIX_BASE_URL`%g" ${pwd}/conf.json
- sed -i '' -e "s%#apisixApiKey#%`echo $APISIX_API_KEY`%g" ${pwd}/conf.json
- sed -i '' -e "s%#apisixDebugUrl#%`echo $APISIX_DEBUG_URL`%g" ${pwd}/conf.json
-else
- sed -i -e "s%#mysqlAddress#%`echo $MYSQL_SERVER_ADDRESS`%g" ${pwd}/conf.json
- sed -i -e "s%#mysqlUser#%`echo $MYSQL_USER`%g" ${pwd}/conf.json
- sed -i -e "s%#mysqlPWD#%`echo $MYSQL_PASSWORD`%g" ${pwd}/conf.json
- sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
- sed -i -e "s%#apisixBaseUrl#%`echo $APISIX_BASE_URL`%g" ${pwd}/conf.json
- sed -i -e "s%#apisixApiKey#%`echo $APISIX_API_KEY`%g" ${pwd}/conf.json
- sed -i -e "s%#apisixDebugUrl#%`echo $APISIX_DEBUG_URL`%g" ${pwd}/conf.json
-fi
-
-
-cp ${pwd}/conf.json ${pwd}/api/conf/conf.json
-
-exec ./manager-api
-
diff --git a/compose/docker-compose.yml b/compose/docker-compose.yml
index c4819c7..4e1e601 100644
--- a/compose/docker-compose.yml
+++ b/compose/docker-compose.yml
@@ -71,21 +71,6 @@ services:
apisix-dashboard:
ipv4_address: 192.17.5.13
- mysql:
- image: mysql:latest
- restart: always
- ports:
- - '3309:3306/tcp'
- environment:
- - MYSQL_ROOT_PASSWORD=123456
- volumes:
- - /tmp/datadir:/var/lib/mysql
- - /tmp/conf.d:/etc/mysql/conf.d
- - ../api/script/db:/docker-entrypoint-initdb.d
- networks:
- apisix-dashboard:
- ipv4_address: 192.17.5.14
-
manager:
build:
context: ./../api
@@ -96,7 +81,7 @@ services:
environment:
- ENV=prod
volumes:
- - ./manager_conf/build.sh:/go/manager-api/build.sh
+ - ./manager_conf/entry.sh:/go/manager-api/entry.sh
networks:
apisix-dashboard:
ipv4_address: 192.17.5.15
diff --git a/api/build.sh b/compose/manager_conf/entry.sh
old mode 100644
new mode 100755
similarity index 62%
rename from api/build.sh
rename to compose/manager_conf/entry.sh
index c734047..34ca263
--- a/api/build.sh
+++ b/compose/manager_conf/entry.sh
@@ -1,5 +1,4 @@
-#!/bin/sh
-#
+#
# 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.
@@ -16,17 +15,24 @@
# limitations under the License.
#
-export ENV=prod
+#!/bin/sh
+
pwd=`pwd`
-sed -i -e "s%#mysqlAddress#%`echo $MYSQL_SERVER_ADDRESS`%g" ${pwd}/conf.json
-sed -i -e "s%#mysqlUser#%`echo $MYSQL_USER`%g" ${pwd}/conf.json
-sed -i -e "s%#mysqlPWD#%`echo $MYSQL_PASSWORD`%g" ${pwd}/conf.json
-sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixBaseUrl#%`echo $APISIX_BASE_URL`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixApiKey#%`echo $APISIX_API_KEY`%g" ${pwd}/conf.json
-sed -i -e "s%#apisixDebugUrl#%`echo $APISIX_DEBUG_URL`%g" ${pwd}/conf.json
+# config
+cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json
+
+export APIX_ETCD_ENDPOINTS="192.17.5.10:2379"
+
+export SYSLOG_HOST=127.0.0.1
+
+if [[ "$unamestr" == 'Darwin' ]]; then
+ sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+else
+ sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
+fi
+
+cp ${pwd}/conf.json ${pwd}/api/conf/conf.json
cd /go/manager-api
exec ./manager-api
-
diff --git a/manager-api.md b/manager-api.md
deleted file mode 100644
index e46d6e4..0000000
--- a/manager-api.md
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
-#
-# 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.
-#
--->
-
-# Apache APISIX Dashboard
-
-## the relation between dashboard and manager-api
-
-At present, the dashboard is divided into two parts, one is the front-end page and script, and the other is the manager that takes over the front-end api interface.
-
-Compared with the previous apisix-dashboard, we have one more manager module, which is used to encapsulate the apisix admin api, which is more suitable for page element display.
-
-The module call relationship is as follows
-
-![manager-api](./images/manager-api.png)
-
-The manager-api has its own storage. The currently used mysql, mysql stores some management information other than APISIX internal objects.
-
-When deploying dashboard, we are divided into 3 modules, namely dashboard page, manager-api, and the mysql database that manager-api depends on. The purple part in the figure is the two new modules added this time.
-
-You can also use docker-compose for one-click deployment, refer to [here](./compose/README.md)