暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

构建Sonarqube8.9.10的arm镜像

632

构建arm镜像

DockerHub上低于9.9.1的版本都没有ARM架构的镜像,根据官方github上的Dockerfile进行微调自己在arm服务器上构建自己的镜像。

下载zip包

下载地址,将下载好的zip放在Dockerfile目录下。这里我使用8版本里最新的8.9.10.61524。

生成源地址文件

这里是debian的国内镜像源,下面构建的基础镜像openjdk:11-jre-slim是基于debian的,可以在DockerHub上查到。

source.list

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
复制

构建镜像

根据官方的Dockerfile进行调整,并复制下来run.sh放到自己的Dockerfile目录。官方Dockerfile地址

#给run.sh执行权限,必须执行 chmod 755 run.sh
复制

Dockerfile,核心就是调整了debian的源和手动下载了指定版本的zip包

FROM openjdk:11-jre-slim COPY sources.list /etc/apt/sources.list RUN apt-get update \ && apt-get install -y curl unzip \ && rm -rf /var/lib/apt/lists/* # Http port EXPOSE 9000 RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqube ARG SONARQUBE_VERSION=8.9.10.61524 ARG SONARQUBE_ZIP_URL=https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${SONARQUBE_VERSION}.zip ENV SONAR_VERSION=${SONARQUBE_VERSION} \ SONARQUBE_HOME=/opt/sq \ SONARQUBE_PUBLIC_HOME=/opt/sonarqube SHELL ["/bin/bash", "-c"] RUN sed -i -e "s?securerandom.source=file:/dev/random?securerandom.source=file:/dev/urandom?g" \ "$JAVA_HOME/conf/security/java.security" COPY sonarqube-8.9.10.61524.zip /opt/sonarqube.zip RUN set -x \ && cd /opt \ # download and unzip SQ # && curl -o sonarqube.zip -fsSL "$SONARQUBE_ZIP_URL" \ && rm -Rf "${SONARQUBE_ZIP_DIR}" \ && unzip -q sonarqube.zip \ && mv "sonarqube-${SONARQUBE_VERSION}" sq \ && rm sonarqube.zip* \ # empty bin directory from useless scripts # create copies or delete directories allowed to be mounted as volumes, original directories will be recreated below as symlinks && rm --recursive --force "$SONARQUBE_HOME/bin"/* \ && mv "$SONARQUBE_HOME/conf" "$SONARQUBE_HOME/conf_save" \ && mv "$SONARQUBE_HOME/extensions" "$SONARQUBE_HOME/extensions_save" \ && rm --recursive --force "$SONARQUBE_HOME/logs" \ && rm --recursive --force "$SONARQUBE_HOME/data" \ # create directories to be declared as volumes # copy into them to ensure they are initialized by 'docker run' when new volume is created # 'docker run' initialization will not work if volume is bound to the host's filesystem or when volume already exists # initialization is implemented in 'run.sh' for these cases && mkdir --parents "$SONARQUBE_PUBLIC_HOME/conf" \ && mkdir --parents "$SONARQUBE_PUBLIC_HOME/extensions" \ && mkdir --parents "$SONARQUBE_PUBLIC_HOME/logs" \ && mkdir --parents "$SONARQUBE_PUBLIC_HOME/data" \ && cp --recursive "$SONARQUBE_HOME/conf_save"/* "$SONARQUBE_PUBLIC_HOME/conf/" \ && cp --recursive "$SONARQUBE_HOME/extensions_save"/* "$SONARQUBE_PUBLIC_HOME/extensions/" \ # create symlinks to volume directories && ln -s "$SONARQUBE_PUBLIC_HOME/conf" "$SONARQUBE_HOME/conf" \ && ln -s "$SONARQUBE_PUBLIC_HOME/extensions" "$SONARQUBE_HOME/extensions" \ && ln -s "$SONARQUBE_PUBLIC_HOME/logs" "$SONARQUBE_HOME/logs" \ && ln -s "$SONARQUBE_PUBLIC_HOME/data" "$SONARQUBE_HOME/data" \ && chown --recursive sonarqube:sonarqube "$SONARQUBE_HOME" "$SONARQUBE_PUBLIC_HOME" && cp --recursive "$SONARQUBE_HOME/extensions_save"/* "$SONARQUBE_PUBLIC_HOME/extensions/" \ # create symlinks to volume directories && ln -s "$SONARQUBE_PUBLIC_HOME/conf" "$SONARQUBE_HOME/conf" \ && ln -s "$SONARQUBE_PUBLIC_HOME/extensions" "$SONARQUBE_HOME/extensions" \ && ln -s "$SONARQUBE_PUBLIC_HOME/logs" "$SONARQUBE_HOME/logs" \ && ln -s "$SONARQUBE_PUBLIC_HOME/data" "$SONARQUBE_HOME/data" \ && chown --recursive sonarqube:sonarqube "$SONARQUBE_HOME" "$SONARQUBE_PUBLIC_HOME" COPY --chown=sonarqube:sonarqube run.sh "$SONARQUBE_HOME/bin/" USER sonarqube WORKDIR $SONARQUBE_HOME ENTRYPOINT ["./bin/run.sh"]
复制

构建,ARM架构的机器上执行

docker build -t test/sonarqube:8.9.10 .
复制

运行构建的镜像

docker run -d --name sq -p 9000:9000 \ --restart=always \ -e SONARQUBE_JDBC_URL=jdbc:postgresql://192.168.10.99:5432/sonar \ -e SONARQUBE_JDBC_USERNAME=sonar \ -e SONARQUBE_JDBC_PASSWORD=sonar@123 \ test/sonarqube:8.9.10
复制

最后修改时间:2023-05-09 11:36:16
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论