This is an automated email from the ASF dual-hosted git repository. vongosling pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/rocketmq-docker.git
commit 6c2baea6897b580e0bf84f34193ae3f781ada5c3 Author: liuruiyiyang <245422...@qq.com> AuthorDate: Wed Aug 7 17:01:06 2019 +0800 Feat(Dockerfile): support openjdk-alpine as base image to provide light-weight image version --- image-build/{Dockerfile => Dockerfile-alpine} | 0 image-build/{Dockerfile => Dockerfile-centos} | 0 .../docker-compose/data1/broker/conf/broker.conf | 2 +- templates/docker-compose/docker-compose.yml | 8 ++-- templates/play-consumer.sh | 16 +++++++ templates/play-docker-compose.sh | 17 ++++++- templates/play-docker-deledger.sh | 17 ++++++- templates/play-docker-tls.sh | 18 +++++++- templates/play-docker.sh | 53 +++++++++++++++++++--- templates/play-kubernetes.sh | 15 ++++++ templates/play-producer.sh | 15 ++++++ 11 files changed, 146 insertions(+), 15 deletions(-) diff --git a/image-build/Dockerfile b/image-build/Dockerfile-alpine similarity index 100% copy from image-build/Dockerfile copy to image-build/Dockerfile-alpine diff --git a/image-build/Dockerfile b/image-build/Dockerfile-centos similarity index 100% rename from image-build/Dockerfile rename to image-build/Dockerfile-centos diff --git a/templates/docker-compose/data1/broker/conf/broker.conf b/templates/docker-compose/data1/broker/conf/broker.conf index acf84fb..37c8a5f 100644 --- a/templates/docker-compose/data1/broker/conf/broker.conf +++ b/templates/docker-compose/data1/broker/conf/broker.conf @@ -1,6 +1,6 @@ brokerClusterName = DefaultCluster brokerName = broker-b -brokerId = 1 +brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER diff --git a/templates/docker-compose/docker-compose.yml b/templates/docker-compose/docker-compose.yml index 64271b9..8d3afab 100644 --- a/templates/docker-compose/docker-compose.yml +++ b/templates/docker-compose/docker-compose.yml @@ -19,7 +19,8 @@ services: - namesrv ports: - 10909:10909 - - 10911:10911 + - 10911:10911 + - 10912:10912 environment: - NAMESRV_ADDR=namesrv:9876 volumes: @@ -31,12 +32,13 @@ services: #Service for another broker -- broker1 broker1: image: rocketmqinc/rocketmq:ROCKETMQ_VERSION - container_name: rmqbroker1 + container_name: rmqbroker-b links: - namesrv ports: - 10929:10909 - - 10931:10911 + - 10931:10911 + - 10932:10912 environment: - NAMESRV_ADDR=namesrv:9876 volumes: diff --git a/templates/play-consumer.sh b/templates/play-consumer.sh index 5f9f6e3..a097ec0 100755 --- a/templates/play-consumer.sh +++ b/templates/play-consumer.sh @@ -1,4 +1,20 @@ #!/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. + + # Consume messages docker exec -ti rmqbroker sh ./tools.sh org.apache.rocketmq.example.quickstart.Consumer \ No newline at end of file diff --git a/templates/play-docker-compose.sh b/templates/play-docker-compose.sh index f1b5c3a..8ff631f 100755 --- a/templates/play-docker-compose.sh +++ b/templates/play-docker-compose.sh @@ -1,5 +1,20 @@ #!/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. + RMQ_CONTAINER=$(docker ps -a|awk '/rmq/ {print $1}') if [[ -n "$RMQ_CONTAINER" ]]; then echo "Removing RocketMQ Container..." @@ -12,5 +27,5 @@ if [ ! -d "`pwd`/data" ]; then mkdir -p "data" fi -# Run namesrv and broker +# Run nameserver and broker docker-compose -f ./docker-compose/docker-compose.yml up -d diff --git a/templates/play-docker-deledger.sh b/templates/play-docker-deledger.sh index 4be6521..119a65c 100755 --- a/templates/play-docker-deledger.sh +++ b/templates/play-docker-deledger.sh @@ -1,5 +1,20 @@ #!/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. + RMQ_CONTAINER=$(docker ps -a|awk '/rmq/ {print $1}') if [[ -n "$RMQ_CONTAINER" ]]; then echo "Removing RocketMQ Container..." @@ -33,7 +48,7 @@ docker run --net dledger-br --ip 172.18.0.12 -d -p 30911:30911 -p 30909:30909 -v docker run --net dledger-br --ip 172.18.0.13 -d -p 30921:30921 -p 30919:30919 -v `pwd`/data/broker1/logs:/home/rocketmq/logs -v `pwd`/data/broker1/store:/home/rocketmq/store -v `pwd`/data/broker1/conf/dledger:/opt/rocketmq-ROCKETMQ_VERSION/conf/dledger --name rmqbroker1 --link rmqnamesrv:namesrv -e "MAX_POSSIBLE_HEAP=200000000" -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:ROCKETMQ_VERSION sh mqbroker -c ../conf/dledger/broker.conf docker run --net dledger-br --ip 172.18.0.14 -d -p 30931:30931 -p 30929:30929 -v `pwd`/data/broker2/logs:/home/rocketmq/logs -v `pwd`/data/broker2/store:/home/rocketmq/store -v `pwd`/data/broker2/conf/dledger:/opt/rocketmq-ROCKETMQ_VERSION/conf/dledger --name rmqbroker2 --link rmqnamesrv:namesrv -e "MAX_POSSIBLE_HEAP=200000000" -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:ROCKETMQ_VERSION sh mqbroker -c ../conf/dledger/broker.conf -# Servive unavailable when not ready +# Service unavailable when not ready # sleep 20 # Produce messages diff --git a/templates/play-docker-tls.sh b/templates/play-docker-tls.sh index 03ff51e..e1ae8fd 100755 --- a/templates/play-docker-tls.sh +++ b/templates/play-docker-tls.sh @@ -1,5 +1,20 @@ #!/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. + RMQ_CONTAINER=$(docker ps -a|awk '/rmq/ {print $1}') if [[ -n "$RMQ_CONTAINER" ]]; then echo "Removing RocketMQ Container..." @@ -15,13 +30,12 @@ fi echo "Starting RocketMQ nodes..." # Start nameserver -# Start nameserver docker run -d -v `pwd`/ssl:/home/rocketmq/ssl -v `pwd`/data/namesrv/logs:/home/rocketmq/logs -v `pwd`/data/namesrv/store:/home/rocketmq/store --name rmqnamesrv -e "JAVA_OPT=-Dtls.test.mode.enable=false -Dtls.config.file=/home/rocketmq/ssl/ssl.properties -Dtls.test.mode.enable=false -Dtls.server.need.client.auth=required" rocketmqinc/rocketmq:ROCKETMQ_VERSION sh mqnamesrv # Start Broker docker run -d -v `pwd`/ssl:/home/rocketmq/ssl -v `pwd`/data/broker/logs:/home/rocketmq/logs -v `pwd`/data/broker/store:/home/rocketmq/store --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPT=-Dtls.enable=true -Dtls.client.authServer=true -Dtls.test.mode.enable=false -Dtls.config.file=/home/rocketmq/ssl/ssl.properties -Dtls.test.mode.enable=false -Dtls.server.mode=enforcing -Dtls.server.need.client.auth=required" rocketmqinc/rocketmq:ROCKETMQ_VERSION [...] -# Servive unavailable when not ready +# Service unavailable when not ready # sleep 20 # Produce messages diff --git a/templates/play-docker.sh b/templates/play-docker.sh index dd2e7fd..de01043 100755 --- a/templates/play-docker.sh +++ b/templates/play-docker.sh @@ -1,5 +1,38 @@ #!/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. + +start_namesrv_broker() +{ + TAG_SUFFIX=$1 + # Start nameserver + docker run -d -v `pwd`/data/namesrv/logs:/home/rocketmq/logs -v `pwd`/data/namesrv/store:/home/rocketmq/store --name rmqnamesrv rocketmqinc/rocketmq:ROCKETMQ_VERSION${TAG_SUFFIX} sh mqnamesrv + # Start Broker + docker run -d -v `pwd`/data/broker/logs:/home/rocketmq/logs -v `pwd`/data/broker/store:/home/rocketmq/store --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:ROCKETMQ_VERSION${TAG_SUFFIX} sh mqbroker +} + +if [ $# -lt 1 ]; then + echo -e "Usage: sh $0 BaseImage" + exit -1 +fi + +export BASE_IMAGE=$1 + +echo "Play RocketMQ docker image of tag ROCKETMQ_VERSION-${BASE_IMAGE}" + RMQ_CONTAINER=$(docker ps -a|awk '/rmq/ {print $1}') if [[ -n "$RMQ_CONTAINER" ]]; then echo "Removing RocketMQ Container..." @@ -14,14 +47,20 @@ fi echo "Starting RocketMQ nodes..." -# Start nameserver -# Start nameserver -docker run -d -v `pwd`/data/namesrv/logs:/home/rocketmq/logs -v `pwd`/data/namesrv/store:/home/rocketmq/store --name rmqnamesrv rocketmqinc/rocketmq:ROCKETMQ_VERSION sh mqnamesrv - -# Start Broker -docker run -d -v `pwd`/data/broker/logs:/home/rocketmq/logs -v `pwd`/data/broker/store:/home/rocketmq/store --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:ROCKETMQ_VERSION sh mqbroker +case "${BASE_IMAGE}" in + alpine) + start_namesrv_broker -alpine + ;; + centos) + start_namesrv_broker + ;; + *) + echo "${BASE_IMAGE} is not supported, supported base images: centos, alpine" + exit -1 + ;; +esac -# Servive unavailable when not ready +# Service unavailable when not ready # sleep 20 # Produce messages diff --git a/templates/play-kubernetes.sh b/templates/play-kubernetes.sh index 6ddd5d5..5a3a539 100755 --- a/templates/play-kubernetes.sh +++ b/templates/play-kubernetes.sh @@ -1,5 +1,20 @@ #!/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. + if [ ! -d "`pwd`/data" ]; then mkdir -p "data" fi diff --git a/templates/play-producer.sh b/templates/play-producer.sh index 657195c..f022a13 100755 --- a/templates/play-producer.sh +++ b/templates/play-producer.sh @@ -1,4 +1,19 @@ #!/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. + # Produce messages docker exec -ti rmqbroker sh ./tools.sh org.apache.rocketmq.example.quickstart.Producer \ No newline at end of file