Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate build and run to 2 scripts #600

Merged
merged 6 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions api/build-tools/schema-sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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.
#
pwd=`pwd`

version="master"
if [[ -n $1 ]]; then
version=$1
fi

rm -rf ./api/build-tools/apisix/
wget https://github.com/apache/apisix/archive/$version.zip

unzip $version.zip
mkdir -p ./api/build-tools/apisix/
mv ./apisix-$version/apisix/* ./api/build-tools/apisix/
rm -rf ./apisix-$version
cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json

echo "sync success:"
echo "${pwd}/api/conf/schema.json"
31 changes: 31 additions & 0 deletions api/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/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`

# 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

# build
cd ./api && go build -o ../manager-api .

echo "done."
37 changes: 0 additions & 37 deletions api/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,7 @@ 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 need a new one
if [[ ! -f "${pwd}/api/conf/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}/api/conf/schema.json
cd ../../
fi

# build
if [[ ! -f "${pwd}/manager-api" ]]; then
cd ./api && go build -o ../manager-api .
cd ../
fi

exec ./manager-api
10 changes: 8 additions & 2 deletions docs/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379"
$ go env -w GOPROXY=https://goproxy.cn,direct
```

3. Build and Run
3. Build

```sh
$ ./api/run.sh &
$ api/build.sh
```

4. Run

```sh
$ api/run.sh &
```

## Build the frontend
Expand Down
10 changes: 8 additions & 2 deletions docs/deploy.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ $ export APIX_ETCD_ENDPOINTS="127.0.0.1:2379,127.0.0.1:3379"
$ go env -w GOPROXY=https://goproxy.cn,direct
```

3. 构建并启动
3. 构建

```sh
$ ./api/run.sh &
$ api/build.sh
```

4. 启动

```sh
$ api/run.sh
```

## 构建前端
Expand Down
16 changes: 15 additions & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,18 @@ $ yarn start

## manager-api

TODO
### Sync jsonschema

To sync jsonschema from Apache APISIX, `Lua` 5.1+ and `zip` need to be preinstalled, then execute this command: `api/build-tools/schema-sync.sh $version`.

NOTE: `$version` should be `master` or Apache APISIX's version.

Example:

```sh
# Using "master"
$ api/build-tools/schema-sync.sh master

# Using Apache APISIX's version
$ api/build-tools/schema-sync.sh 2.0
```
16 changes: 15 additions & 1 deletion docs/develop.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@ $ yarn start

## manager-api 开发

待补充
### 同步 jsonschema

从 Apache APISIX 同步 jsonschema ,需要预安装 `Lua` 5.1+ 和 `zip` ,并执行命令 `api/build-tools/schema-sync.sh $version`。

注意:`$version` 为 `master` 或者 Apache APISIX 的版本号。

示例:

```sh
# 使用 "master"
$ api/build-tools/schema-sync.sh master

# 使用 Apache APISIX 的版本号
$ api/build-tools/schema-sync.sh 2.0
```