This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 36db67435 [type: refactor] Refactor docker-compose yaml and install
script (#3211)
36db67435 is described below
commit 36db6743573efd7e4adc65bce3ee2419b51dde61
Author: Kunshuai Zhu <[email protected]>
AuthorDate: Thu Apr 14 22:44:39 2022 +0800
[type: refactor] Refactor docker-compose yaml and install script (#3211)
* [type: refactor] Refactor docker-compose yaml and install script
* uncomment debug
* Add readme
* Add v
* Add v
---
shenyu-dist/shenyu-docker-compose-dist/README.md | 17 ++++++
.../{stand-alone-h2 => }/docker-compose.yaml | 28 ++++++----
.../src/main/resources/install.sh | 63 ++++++++++++++-------
.../stand-alone-mysql/docker-compose.yaml | 65 ----------------------
.../resources/stand-alone-pg/docker-compose.yaml | 65 ----------------------
5 files changed, 76 insertions(+), 162 deletions(-)
diff --git a/shenyu-dist/shenyu-docker-compose-dist/README.md
b/shenyu-dist/shenyu-docker-compose-dist/README.md
new file mode 100644
index 000000000..f570d20e5
--- /dev/null
+++ b/shenyu-dist/shenyu-docker-compose-dist/README.md
@@ -0,0 +1,17 @@
+### Run ShenYu By docker-compose
+
+1. Execute the install-script.
+
+```shell
+$ curl -O
https://raw.githubusercontent.com/apache/incubator-shenyu/master/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/install.sh
+
+$ sh ./install.sh ${version} #please replace the ${version}, such as v2.4.2 or
latest
+```
+
+2. Modify the configuration file.
+
+3. Start docker-compose
+
+```shell
+docker-compose -f ./docker-compose.yaml up -d
+```
diff --git
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-h2/docker-compose.yaml
b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/docker-compose.yaml
similarity index 62%
rename from
shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-h2/docker-compose.yaml
rename to
shenyu-dist/shenyu-docker-compose-dist/src/main/resources/docker-compose.yaml
index 5d93dd9d9..d89b11ff3 100644
---
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-h2/docker-compose.yaml
+++
b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/docker-compose.yaml
@@ -21,23 +21,27 @@ services:
image: apache/shenyu-bootstrap:latest
container_name: shenyu-bootstrap
ports:
- - "9195:9195"
+ - "9195:9195"
volumes:
- - ./shenyu-bootstrap/logs/:/opt/shenyu-bootstrap/logs
- - ./shenyu-bootstrap/conf/:/opt/shenyu-bootstrap/conf
- links:
- - shenyu-admin:admin
+ - ./shenyu-bootstrap/logs/:/opt/shenyu-bootstrap/logs
+ - ./shenyu-bootstrap/conf/:/opt/shenyu-bootstrap/conf
depends_on:
- - shenyu-admin
+ - shenyu-admin
environment:
- - shenyu.sync.websocket.urls=ws://admin:9095/websocket
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
shenyu-admin:
image: apache/shenyu-admin:latest
container_name: shenyu-admin
volumes:
- - ./shenyu-admin/logs/:/opt/shenyu-admin/logs
- - ./shenyu-admin/conf/:/opt/shenyu-admin/conf
- environment:
- - spring.profiles.active=h2
+ - ./shenyu-admin/logs/:/opt/shenyu-admin/logs
+ - ./shenyu-admin/conf/:/opt/shenyu-admin/conf
ports:
- - "9095:9095"
\ No newline at end of file
+ - "9095:9095"
+ healthcheck:
+ test: [ "CMD-SHELL", "wget -q -O -
http://shenyu-admin:9095/actuator/health | grep UP || exit 1" ]
+ timeout: 2s
+ retries: 30
diff --git
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/install.sh
b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/install.sh
index d70454b5f..147613d8a 100644
--- a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/install.sh
+++ b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/install.sh
@@ -15,11 +15,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+function check_sed() {
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ if ! which gsed >/dev/null 2>&1; then
+ echo "Please install gsed, you can run 'brew install gnu-sed'"
+ exit 1
+ fi
+ elif [[ "$OSTYPE" == "linux"* ]]; then
+ if ! which sed >/dev/null 2>&1; then
+ echo "Please install sed, you can run 'apt-get install sed'"
+ exit 1
+ fi
+ else
+ echo "Unknown operating system: $OSTYPE"
+ exit 1
+ fi
+}
+
version=${1}
-storage=${2}
+
+if [[ $version != v* && $version != 'latest' ]]; then
+ echo "The version should start with 'v', such as 'v2.4.2' or 'latest'."
+ exit 1
+fi
echo "current version: ${version}"
-echo "current storage: ${storage}"
mkdir shenyu-${version}
@@ -27,31 +47,34 @@ cd shenyu-${version}
mkdir -p {shenyu-bootstrap,shenyu-admin}/{conf,logs}
-echo "download docker-compose configuration"
-curl -sSl
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-${storage}/docker-compose.yaml
> docker-compose.yaml
+echo "Downloading docker-compose configuration ..."
+curl -sSl
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/docker-compose.yaml
> docker-compose.yaml
-if [ ! -f "./docker-compose.yaml" ];then
- # shellcheck disable=SC2016
- exit 0
-fi
-
-if [ "$version" != "master" ];then
- # shellcheck disable=SC2016
+if [ "$version" != "latest" ];then
+ check_sed
newVersion=${version#"v"}
- sed -i 's/latest/'"${newVersion}"'/g' docker-compose.yaml
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ gsed -i 's/latest/'"${newVersion}"'/g' docker-compose.yaml
+ elif [[ "$OSTYPE" == "linux"* ]]; then
+ sed -i 's/latest/'"${newVersion}"'/g' docker-compose.yaml
+ fi
fi
-if [ "$storage" = "mysql" ];then
- mkdir -p shenyu-admin/ext-lib
- echo "download mysql-connector.jar"
- (cd shenyu-admin/ext-lib && curl -o mysql-connector.jar
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar)
-fi
+mkdir -p shenyu-admin/ext-lib
+echo "Downloading mysql-connector.jar ..."
+(cd shenyu-admin/ext-lib && curl -o mysql-connector.jar
https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.18/mysql-connector-java-8.0.18.jar)
-echo "download shenyu-admin of configuration"
+printf '\n'
+echo "Downloading shenyu-admin configuration ..."
(cd shenyu-admin/conf/ && curl -OOOO
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-admin/src/main/resources/{application-mysql.yml,application.yml,application-h2.yml,application-pg.yml})
(cd shenyu-admin/conf/ && curl -O
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-dist/shenyu-admin-dist/src/main/resources/logback.xml)
-echo "download shenyu-bootstrap of configuration"
+
+printf '\n'
+echo "Downloading shenyu-bootstrap configuration ..."
(cd shenyu-bootstrap/conf/ && curl -O
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-bootstrap/src/main/resources/application.yml)
(cd shenyu-bootstrap/conf/ && curl -O
https://raw.githubusercontent.com/apache/incubator-shenyu/${version}/shenyu-dist/shenyu-bootstrap-dist/src/main/resources/logback.xml)
-docker-compose up -d
\ No newline at end of file
+printf '\n'
+echo "Next steps? Please modify the configuration in ./shenyu-${version}"
+echo "And then, you can run docker-compose"
+echo "For more detail, see https://shenyu.apache.org/docs/index"
diff --git
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-mysql/docker-compose.yaml
b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-mysql/docker-compose.yaml
deleted file mode 100644
index c0032624b..000000000
---
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-mysql/docker-compose.yaml
+++ /dev/null
@@ -1,65 +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.
-#
-
-version: "2.1"
-services:
- shenyu-bootstrap:
- image: apache/shenyu-bootstrap:latest
- container_name: shenyu-bootstrap
- ports:
- - "9195:9195"
- volumes:
- - ./shenyu-bootstrap/logs/:/opt/shenyu-bootstrap/logs
- - ./shenyu-bootstrap/conf/:/opt/shenyu-bootstrap/conf
- links:
- - shenyu-admin:admin
- depends_on:
- - shenyu-admin
- environment:
- - shenyu.sync.websocket.urls=ws://admin:9095/websocket
- shenyu-admin:
- image: apache/shenyu-admin:latest
- container_name: shenyu-admin
- environment:
- - spring.profiles.active=mysql
- -
spring.datasource.url=jdbc:mysql://db:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false
- - spring.datasource.username=root
- - spring.datasource.password=xyzj1a2y3
- volumes:
- - ./shenyu-admin/logs/:/opt/shenyu-admin/logs
- - ./shenyu-admin/conf/:/opt/shenyu-admin/conf
- - ./shenyu-admin/ext-lib/:/opt/shenyu-admin/ext-lib
- ports:
- - "9095:9095"
- links:
- - db:db
- depends_on:
- db:
- condition: service_healthy
- db:
- image: docker.io/mysql:5.7
- container_name: db
- environment:
- MYSQL_ROOT_PASSWORD: xyzj1a2y3
- MYSQL_DATABASE: shenyu
- ports:
- - 3310:3306
- healthcheck:
- test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot",
"-pxyzj1a2y3" ]
- interval: 6s
- timeout: 5s
- retries: 10
diff --git
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-pg/docker-compose.yaml
b/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-pg/docker-compose.yaml
deleted file mode 100644
index 9361beba7..000000000
---
a/shenyu-dist/shenyu-docker-compose-dist/src/main/resources/stand-alone-pg/docker-compose.yaml
+++ /dev/null
@@ -1,65 +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.
-#
-
-version: "2.1"
-services:
- shenyu-bootstrap:
- image: apache/shenyu-bootstrap:latest
- container_name: shenyu-bootstrap
- ports:
- - "9195:9195"
- volumes:
- - ./shenyu-bootstrap/logs/:/opt/shenyu-bootstrap/logs
- - ./shenyu-bootstrap/conf/:/opt/shenyu-bootstrap/conf
- links:
- - shenyu-admin:admin
- depends_on:
- - shenyu-admin
- environment:
- - shenyu.sync.websocket.urls=ws://admin:9095/websocket
- shenyu-admin:
- image: apache/shenyu-admin:latest
- container_name: shenyu-admin
- volumes:
- - ./shenyu-admin/logs/:/opt/shenyu-admin/logs
- - ./shenyu-admin/conf/:/opt/shenyu-admin/conf
- environment:
- - spring.profiles.active=pg
- - spring.datasource.url=jdbc:postgresql://db:5432/shenyu
- - spring.datasource.username=postgres
- - spring.datasource.password=123456
- ports:
- - "9095:9095"
- links:
- - db:db
- depends_on:
- db:
- condition: service_healthy
- db:
- image: postgres
- container_name: db
- environment:
- POSTGRES_DB: shenyu
- POSTGRES_USER: postgres
- POSTGRES_PASSWORD: 123456
- ports:
- - 5432:5432
- healthcheck:
- test: ["CMD-SHELL", "pg_isready"]
- interval: 6s
- timeout: 5s
- retries: 10
\ No newline at end of file