Merge pull request #44 from francisoliverlee/dev/11-08-add-building-dashboard-image
Add building rocketmq dashboard docker image
diff --git a/README.md b/README.md
index 47b7edb..0c6ef3f 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,12 @@
1. Generate a RocketMQ Docker image
2. Run the docker image with the below modes:
- 1. Single Node.
- 2. Cluster with docker-compose.
- 3. Cluster on Kubernetes.
-
+ 2.1. Single Node.
+ 2.2. Cluster with docker-compose.
+ 2.3. Cluster on Kubernetes.
+ 2.4. Cluster of Dledger storage
+3. TLS support
+4. Generate a RocketMQ Dashboard Docker image
## Prerequisites
@@ -43,7 +45,7 @@
> Note: RMQ-VERSION is the tag of the RocketMQ image.
After executing the above shell script, (e.g. sh stage.sh 4.5.0), it will generate a stage directory (./stages/4.5.0). User can do the following works under the directory, assuming the RMQ-version is defined with 4.5.0.
-#### 1. Single Node
+#### 2.1 Single Node
Run:
@@ -58,7 +60,7 @@
```stages/4.5.0/template```, please adjust the command accordingly.
-#### 2. Cluster with docker-compose
+#### 2.2 Cluster with docker-compose
Run:
@@ -70,7 +72,7 @@
```
-#### 3. Cluster on Kubernetes
+#### 2.3 Cluster on Kubernetes
Run:
@@ -81,7 +83,7 @@
```
-#### 4. Cluster of Dledger storage
+#### 2.4 Cluster of Dledger storage
Run: (Note: This feature needs RMQ version is 4.4.0 or above)
@@ -92,7 +94,7 @@
```
-## 5. TLS support
+## 3. TLS support
Run: (It will startup nameserver and broker with SSL enabled style. The client will not invoke nameserver or broker until related SSL client is configurated. )
@@ -108,6 +110,22 @@
./play-consumer.sh
```
+## 4. Generate a RocketMQ Dashboard Docker image
+- 4.1 build command
+```
+cd image-build && sh build-image-dashboard.sh `VERSION` centos
+
+demo: sh build-image-dashboard.sh 1.0.0 centos
+```
+
+- 4.2 start command
+```
+sh product/start-dashboard.sh `VERSION`
+
+demo: sh product/start-dashboard.sh 1.0.0
+```
+
+
### How to update RocketMQ image repository using update.sh
Run:
diff --git a/image-build/Dockerfile-centos-dashboard b/image-build/Dockerfile-centos-dashboard
new file mode 100644
index 0000000..492809e
--- /dev/null
+++ b/image-build/Dockerfile-centos-dashboard
@@ -0,0 +1,94 @@
+#
+# 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 centos:7
+
+RUN yum install -y java-1.8.0-openjdk-devel.x86_64 unzip openssl, which gnupg, wget \
+ && yum clean all -y
+
+# FROM openjdk:8-jdk
+# RUN apt-get update && apt-get install -y --no-install-recommends \
+# bash libapr1 unzip telnet wget gnupg ca-certificates \
+# && rm -rf /var/lib/apt/lists/*
+
+ARG user=rocketmq
+ARG group=rocketmq
+ARG uid=3000
+ARG gid=3000
+
+# RocketMQ Dashboard runs with user `rocketmq`, uid = 3000
+# If you bind mount a volume from the host or a data container,
+# ensure you use the same uid
+RUN groupadd -g ${gid} ${group} \
+ && useradd -u ${uid} -g ${gid} -m -s /bin/bash ${user}
+
+ARG version
+
+# install maven 3.6.3
+ARG MAVEN_VERSION=3.6.3
+ARG MAVEN_DOWNLOAD_URL=https://dlcdn.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz
+
+RUN mkdir -p /usr/share/maven /usr/share/maven/ref && \
+ wget -O /tmp/apache-maven.tar.gz ${MAVEN_DOWNLOAD_URL} --no-check-certificate && \
+ tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 && \
+ rm -f /tmp/apache-maven.tar.gz && \
+ ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
+
+### make it faster if remove those "#"s bellow
+# RUN sed -i '159i \
+# <mirror> \
+# <id>nexus-tencentyun</id> \
+# <mirrorOf>*</mirrorOf> \
+# <name>Nexus tencentyun</name> \
+# <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url> \
+# </mirror> \
+# ' /usr/share/maven/conf/settings.xml
+
+RUN cat /usr/share/maven/conf/settings.xml
+
+ENV ROCKETMQ_DASHBOARD_VERSION ${version}
+ENV ROCKETMQ_DASHBOARD_HOME /home/rocketmq/rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}
+WORKDIR ${ROCKETMQ_DASHBOARD_HOME}
+
+RUN set -eux; \
+ curl -L https://dist.apache.org/repos/dist/release/rocketmq/rocketmq-dashboard/${ROCKETMQ_DASHBOARD_VERSION}/rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}-source-release.zip -o rocketmq-dashboard.zip; \
+ curl -L https://dist.apache.org/repos/dist/release/rocketmq/rocketmq-dashboard/${ROCKETMQ_DASHBOARD_VERSION}/rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}-source-release.zip.asc -o rocketmq-dashboard.zip.asc; \
+ wget https://www.apache.org/dist/rocketmq/KEYS --no-check-certificate; \
+ \
+ gpg --import KEYS; \
+ gpg --batch --verify rocketmq-dashboard.zip.asc rocketmq-dashboard.zip ; \
+ unzip rocketmq-dashboard.zip ; \
+ rm rocketmq-dashboard.zip rocketmq-dashboard.zip.asc KEYS;
+
+RUN cd rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION} ; \
+ mvn -DskipTests clean install ;\
+ ls -l target ;
+
+
+RUN mkdir bin; \
+ mv rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}/target/rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}.jar bin/ ; \
+ mv bin/rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}.jar bin/rocketmq-dashboard.jar; \
+ ls -l bin; \
+ rm -rf rocketmq-dashboard-${ROCKETMQ_DASHBOARD_VERSION}
+
+RUN rm -rf /root/.m2/repository/*
+RUN rm -rf /usr/share/maven
+RUN yum remove wget unzip openssl -y
+
+RUN chown -R ${uid}:${gid} ${ROCKETMQ_DASHBOARD_HOME}
+EXPOSE 8080
+ENTRYPOINT ["java", "-jar", "bin/rocketmq-dashboard.jar"];
\ No newline at end of file
diff --git a/image-build/build-image-dashboard.sh b/image-build/build-image-dashboard.sh
new file mode 100644
index 0000000..22339c4
--- /dev/null
+++ b/image-build/build-image-dashboard.sh
@@ -0,0 +1,49 @@
+#!/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.
+
+checkVersion() {
+ echo "Version = $1"
+ echo $1 |grep -E "^[0-9]+\.[0-9]+\.[0-9]+" > /dev/null
+ if [ $? = 0 ]; then
+ return 1
+ fi
+
+ echo "Version $1 illegal, it should be X.X.X format(e.g. 4.5.0), please check released versions in 'https://archive.apache.org/dist/rocketmq/'"
+ exit -1
+}
+
+if [ $# -lt 2 ]; then
+ echo -e "Usage: sh $0 Version BaseImage"
+ exit -1
+fi
+
+ROCKETMQ_DASHBOARD_VERSION=$1
+BASE_IMAGE=$2
+
+checkVersion $ROCKETMQ_DASHBOARD_VERSION
+
+# Build rocketmq
+case "${BASE_IMAGE}" in
+ centos)
+ docker build --no-cache -f Dockerfile-centos-dashboard -t apache/rocketmq-dashboard:${ROCKETMQ_DASHBOARD_VERSION}-centos --build-arg version=${ROCKETMQ_DASHBOARD_VERSION} .
+ ;;
+ *)
+ echo "${BASE_IMAGE} is not supported, supported base images: centos"
+ exit -1
+ ;;
+esac
+
diff --git a/product/start-dashboard.sh b/product/start-dashboard.sh
new file mode 100644
index 0000000..b5ea51e
--- /dev/null
+++ b/product/start-dashboard.sh
@@ -0,0 +1,20 @@
+#!/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.
+
+ROCKETMQ_DASHBOARD_VERSION=$1
+
+docker run -d -it --name rocketmq-dashboard -p 6765:8080 apache/rocketmq-dashboard:${ROCKETMQ_DASHBOARD_VERSION}-centos
\ No newline at end of file