From c8571eef3cbb513f7562c17fc17e13c888780c66 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 15 Jan 2019 14:39:05 -0800 Subject: [PATCH] Add gerrit image jobs Add jobs to build, upload, and promote a gerrit image to Docker Hub. This uses alternative tags, build path, and build args. Change-Id: Iea7109f9ee0ec18431f298a2ecc611678a868d6d Co-Authored-By: Monty Taylor --- .zuul.yaml | 60 ++++++++++++++++++++++++++++++++++++++ docker/gerrit/Dockerfile | 62 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 docker/gerrit/Dockerfile diff --git a/.zuul.yaml b/.zuul.yaml index 0956fe204f..559b845106 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -166,6 +166,63 @@ vars: *gitea_vars files: *gitea_files +# Gerrit jobs +- job: + name: system-config-build-image-gerrit + description: Build a gerrit image. + parent: system-config-build-image + pre-run: playbooks/zuul/gerrit/repos.yaml + required-projects: &gerrit_projects + - name: gerrit.googlesource.com/gerrit + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/commit-message-length-validator + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/download-commands + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/hooks + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/its-base + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/its-storyboard + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/javamelody + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/replication + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/reviewnotes + override-checkout: stable-2.15 + - name: gerrit.googlesource.com/plugins/singleusergroup + override-checkout: stable-2.15 + vars: &gerrit_vars + images: + - context: docker/gerrit + target: gerrit + repository: opendevorg/gerrit + path: /home/zuul/src/gerrit.googlesource.com/gerrit + tags: + - 2.15 + build_args: + - BAZEL_OPTS="--local_resources=4096,2.0,1.0" + files: &gerrit_files + - docker/gerrit/.* + - playbooks/zuul/gerrit/.* + +- job: + name: system-config-upload-image-gerrit + description: Build and upload a gerrit image. + parent: system-config-upload-image + pre-run: playbooks/zuul/gerrit/repos.yaml + required-projects: *gerrit_projects + vars: *gerrit_vars + files: *gerrit_files + +- job: + name: system-config-promote-image-gerrit + description: Promote a previously published gerrit image to latest. + parent: system-config-promote-image + vars: *gerrit_vars + files: *gerrit_files + # Role integration jobs. These test the top-level generic roles/* # under Zuul. The range of platforms should be the same as those for # openstack-zuul-jobs. @@ -451,6 +508,7 @@ - system-config-build-image-jinja-init - system-config-build-image-gitea-init - system-config-build-image-gitea + - system-config-build-image-gerrit gate: jobs: - tox-linters @@ -467,8 +525,10 @@ - system-config-upload-image-jinja-init - system-config-upload-image-gitea-init - system-config-upload-image-gitea + - system-config-upload-image-gerrit promote: jobs: - system-config-promote-image-jinja-init - system-config-promote-image-gitea-init - system-config-promote-image-gitea + - system-config-promote-image-gerrit diff --git a/docker/gerrit/Dockerfile b/docker/gerrit/Dockerfile new file mode 100644 index 0000000000..ce94e845ab --- /dev/null +++ b/docker/gerrit/Dockerfile @@ -0,0 +1,62 @@ +# Copyright (c) 2019 Red Hat, Inc. +# +# Licensed 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 openjdk:8 as builder + +RUN groupadd builder && \ + useradd builder --home-dir /usr/src --create-home -g builder +RUN \ + echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && curl -sL https://bazel.build/bazel-release.pub.gpg | apt-key add - \ + && curl -sL https://deb.nodesource.com/setup_8.x | bash - \ + && apt-get update \ + && apt-get install -y bazel nodejs build-essential zip unzip python maven + +COPY . /usr/src +RUN chown -R builder /usr/src + +USER builder +ARG BAZEL_OPTS +RUN cd /usr/src && bazel build release ${BAZEL_OPTS} && mv bazel-bin/release.war gerrit.war + +FROM openjdk:8 + +RUN apt-get update \ + && apt-get install -y dumb-init \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN addgroup gerrit --system \ + && adduser \ + --system \ + --home /var/gerrit \ + --shell /bin/bash \ + --ingroup gerrit \ + gerrit + +USER gerrit +RUN mkdir /var/gerrit/bin +COPY --from=builder /usr/src/gerrit.war /var/gerrit/bin/gerrit.war + +# Allow incoming traffic +EXPOSE 29418 8080 + +VOLUME /var/gerrit/git /var/gerrit/index /var/gerrit/cache /var/gerrit/db /etc/gerrit /var/log/gerrit + +RUN ln -s /var/log/gerrit /var/gerrit/logs && \ + ln -s /etc/gerrit /var/gerrit/config + +ENTRYPOINT ["/usr/bin/dumb-init", "--"] +CMD ["/usr/bin/java", "-jar", "/var/gerrit/bin/gerrit.war"]