Skip to content

Commit

Permalink
[ISSUE #66] Add rocketmq5.x helm chart for CI (#69)
Browse files Browse the repository at this point in the history
* add helm chart use by ci

* update build-image-local.sh

* update dockerfile.sh

* update dockerfile.sh

* update dockerfile.sh

* update dockerfile.sh

* update helm

* update dockerfile

* update dockerfile

* update proxy deployment.yaml and Dockerfile-centos

* update helm chart

* update helm chart

* update dockerfile

* update build-image-local.sh

* update build-image-local.sh

* update build-image-local.sh

* update customize.sh

* update build-image-local.sh

* update dockerfile

* support jacoco

* support jacoco

* support jacoco

* support jacoco

* support jacoco

* update script

* update scripts

* update scripts

---------

Co-authored-by: 月伢 <[email protected]>
  • Loading branch information
cryptoya and 月伢 authored Feb 6, 2023
1 parent 26c9937 commit 6caf9c7
Show file tree
Hide file tree
Showing 25 changed files with 1,482 additions and 0 deletions.
81 changes: 81 additions & 0 deletions image-build-ci/Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# 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.
#

ARG BASE_IMAGE
FROM $BASE_IMAGE

RUN apk add --no-cache bash gettext nmap-ncat openssl busybox-extras libc6-compat

ARG user=rocketmq
ARG group=rocketmq
ARG uid=3000
ARG gid=3000

# RocketMQ is run 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 addgroup --gid ${gid} ${group} \
&& adduser --uid ${uid} -G ${group} ${user} -s /bin/bash -D

ARG version

# Rocketmq version
ENV ROCKETMQ_VERSION ${version}

# Rocketmq home
ENV ROCKETMQ_HOME /home/rocketmq/rocketmq-${ROCKETMQ_VERSION}

WORKDIR ${ROCKETMQ_HOME}

# Install
COPY rocketmq/ ${ROCKETMQ_HOME}/dist

RUN mv ${ROCKETMQ_HOME}/dist/rocketmq*/rocketmq*/* ${ROCKETMQ_HOME}/; \
rm -rf ${ROCKETMQ_HOME}/dist; \
ls ${ROCKETMQ_HOME}

# Copy customized scripts
COPY scripts ${ROCKETMQ_HOME}/bin/

RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}


# Expose namesrv&proxy port
EXPOSE 9876 8080 8081 7001

RUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqadmin \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqnamesrv \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqproxy

# Expose broker port
EXPOSE 10909 10911 10912

RUN mv ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqbroker

# Export Java options
RUN export JAVA_OPT=" -Duser.home=/opt"

# Add ${JAVA_HOME}/lib/ext as java.ext.dirs
RUN sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh

USER ${user}

WORKDIR ${ROCKETMQ_HOME}/bin
87 changes: 87 additions & 0 deletions image-build-ci/Dockerfile-centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#
# 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.
#

ARG BASE_IMAGE
FROM $BASE_IMAGE

RUN yum install -y java-1.8.0-openjdk-devel.x86_64 unzip gettext nmap-ncat openssl, which gnupg, telnet \
&& 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 is run 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

# Rocketmq version
ENV ROCKETMQ_VERSION ${version}

# Rocketmq home
ENV ROCKETMQ_HOME /home/rocketmq/rocketmq-${ROCKETMQ_VERSION}

WORKDIR ${ROCKETMQ_HOME}

# Install
COPY rocketmq/ ${ROCKETMQ_HOME}/dist

RUN mv ${ROCKETMQ_HOME}/dist/rocketmq*/rocketmq*/* ${ROCKETMQ_HOME}/; \
rm -rf ${ROCKETMQ_HOME}/dist; \
ls ${ROCKETMQ_HOME}

# Copy customized scripts
COPY scripts ${ROCKETMQ_HOME}/bin/

RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}


# Expose namesrv&proxy port
EXPOSE 9876 8080 8081 7001

RUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqadmin \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqnamesrv \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqproxy

# Expose broker port
EXPOSE 10909 10911 10912

RUN mv ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqbroker

# export Java options
RUN export JAVA_OPT=" -Duser.home=/opt"

# Add ${JAVA_HOME}/lib/ext as java.ext.dirs
RUN sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh

USER ${user}

WORKDIR ${ROCKETMQ_HOME}/bin
87 changes: 87 additions & 0 deletions image-build-ci/Dockerfile-ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#
# 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.
#

ARG BASE_IMAGE
FROM $BASE_IMAGE

RUN apt-get update && apt-get install -y --no-install-recommends \
bash unzip telnet wget gnupg ca-certificates

ARG user=rocketmq
ARG group=rocketmq
ARG uid=3000
ARG gid=3000

# RocketMQ is run 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

# Rocketmq version
ENV ROCKETMQ_VERSION ${version}

# Rocketmq home
ENV ROCKETMQ_HOME /home/rocketmq/rocketmq-${ROCKETMQ_VERSION}

WORKDIR ${ROCKETMQ_HOME}

# Install
COPY rocketmq/ ${ROCKETMQ_HOME}/dist

RUN mv ${ROCKETMQ_HOME}/dist/rocketmq*/rocketmq*/* ${ROCKETMQ_HOME}/; \
rm -rf ${ROCKETMQ_HOME}/dist; \
ls ${ROCKETMQ_HOME}

# Copy customized scripts
COPY scripts ${ROCKETMQ_HOME}/bin/

RUN chown -R ${uid}:${gid} ${ROCKETMQ_HOME}


# Expose namesrv&proxy port
EXPOSE 9876 8080 8081 7001 2023

RUN wget https://repo1.maven.org/maven2/org/jacoco/jacoco/0.8.8/jacoco-0.8.8.zip -O jacoco-0.8.8.zip && \
unzip jacoco-0.8.8.zip -d jacoco

ENV JAVA_OPT="-javaagent:${ROCKETMQ_HOME}/jacoco/lib/jacocoagent.jar=includes=*,output=tcpserver,port=2023,address=0.0.0.0"

RUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqadmin \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqnamesrv \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqproxy

# Expose broker port
EXPOSE 10909 10911 10912

RUN mv ${ROCKETMQ_HOME}/bin/runbroker-customize.sh ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runbroker.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqbroker

# export Java options
RUN export JAVA_OPT=" -Duser.home=/opt"

# Add ${JAVA_HOME}/lib/ext as java.ext.dirs
RUN sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh

USER ${user}

WORKDIR ${ROCKETMQ_HOME}/bin
80 changes: 80 additions & 0 deletions image-build-ci/build-image-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/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.

if [ $# -lt 6 ]; then
echo -e "Usage: sh $0 ROCKETMQ_VERSION BASE_IMAGE JAVA_VERSION IMAGE_REPO IMAGE_REPO_USERNAME IMAGE_REPO_PASSWORD"
exit -1
fi

ROCKETMQ_VERSION=$1
BASE_IMAGE=$2
JAVA_VERSION=$3
IMAGE_REPO=$4
IMAGE_REPO_USERNAME=$5
IMAGE_REPO_PASSWORD=$6

TAG=${ROCKETMQ_VERSION}-$(echo $BASE_IMAGE | sed -e "s/:/-/g")

cp -r ../../rocketmq ./

docker login --username=$IMAGE_REPO_USERNAME --password=$IMAGE_REPO_PASSWORD ${IMAGE_REPO%%/*}

# Build rocketmq
case "${BASE_IMAGE}" in
#alpine)
# if [ "$JAVA_VERSION" -eq 8 ]; then
# docker build --no-cache -f Dockerfile-alpine -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:8-jre-alpine .
# elif [ "$JAVA_VERSION" -eq 11 ]; then
# docker build --no-cache -f Dockerfile-alpine -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:11-jre-alpine .
# else
# echo "in ${BASE_IMAGE}, jdk ${JAVA_VERSION} is not supported, supported java versions: 8, 11"
# fi
# ;;
#centos)
# if [ "$JAVA_VERSION" -eq 8 ]; then
# docker build --no-cache -f Dockerfile-centos -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:8-centos7 .
# elif [ "$JAVA_VERSION" -eq 11 ]; then
# docker build --no-cache -f Dockerfile-centos -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:11-centos7 .
# else
# echo "in ${BASE_IMAGE}, jdk ${JAVA_VERSION} is not supported, supported java versions: 8, 11"
# fi
# ;;
ubuntu)
if [ "$JAVA_VERSION" -eq 8 ]; then
docker build --no-cache -f Dockerfile-ubuntu -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:8-jre .
# elif [ "$JAVA_VERSION" -eq 11 ]; then
# docker build --no-cache -f Dockerfile-ubuntu -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:11-jre .
else
echo "in ${BASE_IMAGE}, jdk ${JAVA_VERSION} is not supported, supported java versions: 8, 11"
fi
;;
#windows)
# if [ "$JAVA_VERSION" -eq 8 ]; then
# docker build --no-cache -f Dockerfile-windows -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:8-jre-windowsservercore .
# elif [ "$JAVA_VERSION" -eq 11 ]; then
# docker build --no-cache -f Dockerfile-windows -t ${IMAGE_REPO}:${TAG} --build-arg version=${ROCKETMQ_VERSION} --build-arg BASE_IMAGE=eclipse-temurin:11-jre-windowsservercore .
# else
# echo "in ${BASE_IMAGE}, jdk ${JAVA_VERSION} is not supported, supported java versions: 8, 11"
# fi
# ;;
*)
echo "${BASE_IMAGE} is not supported, supported base images: ubuntu, centos, alpine, windows"
exit -1
;;
esac

docker push ${IMAGE_REPO}:${TAG}
Loading

0 comments on commit 6caf9c7

Please sign in to comment.