diff --git a/docker/gerrit/bazel/Dockerfile b/docker/gerrit/bazel/Dockerfile index 8966162f4e..67bb3e9361 100644 --- a/docker/gerrit/bazel/Dockerfile +++ b/docker/gerrit/bazel/Dockerfile @@ -17,15 +17,10 @@ FROM docker.io/opendevorg/gerrit-base as gerrit -COPY release.war /var/gerrit/bin/gerrit.war +COPY bazel-bin/release.war /var/gerrit/bin/gerrit.war # Install plugins RUN mkdir /var/gerrit/plugins && \ unzip -jo /var/gerrit/bin/gerrit.war WEB-INF/plugins/* -d /var/gerrit/plugins COPY opendevtheme.html /var/gerrit/plugins/opendevtheme.html - -FROM gerrit as gerrit-2 - -# Only Gerrit 2.14, 2.15, and 2.16 need this COPY -COPY javamelody-deps_deploy.jar /var/gerrit/lib/javamelody-deps_deploy.jar diff --git a/playbooks/zuul/gerrit/run.yaml b/playbooks/zuul/gerrit/run.yaml index 54e05745a2..56c7b3dce7 100644 --- a/playbooks/zuul/gerrit/run.yaml +++ b/playbooks/zuul/gerrit/run.yaml @@ -12,6 +12,28 @@ vars: zuul_work_dir: /home/zuul/src/gerrit.googlesource.com/gerrit + # Bazel makes "convenience symlinks" [1] starting with bazel-* to + # the actual build output. The problem is that we want to use the + # source tree as the context/build dir for our Docker container, + # and Docker refuses to follow symlinks for COPY commands; i.e. we + # can't copy stuff from the build output into the container. + # Therefore break the bazel-bin link and move to the top level so + # we can copy the built bits (jars, plugins, etc) into the + # container easily. + # + # [1] https://docs.bazel.build/versions/master/user-manual.html + - name: Make bazel-bin docker friendly + shell: + cmd: | + if [ ! -L bazel-bin ]; then + echo "bazel-bin not a symlink?" + exit 1 + fi + target=$(readlink bazel-bin) + rm bazel-bin + mv $target bazel-bin + chdir: /home/zuul/src/gerrit.googlesource.com/gerrit + - name: Install OpenDev theme plugin copy: src: opendevtheme.html diff --git a/roles/bazelisk-build/tasks/main.yaml b/roles/bazelisk-build/tasks/main.yaml index 2a6c7f9dc1..e75e0f97a4 100644 --- a/roles/bazelisk-build/tasks/main.yaml +++ b/roles/bazelisk-build/tasks/main.yaml @@ -3,13 +3,11 @@ set -x java -fullversion {{ bazelisk_executable }} version - {{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets|join(' ') }} - if [[ -f bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar ]] ; then - # versions 2.14, 2.15, and 2.16 generate this file - cp bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar javamelody-deps_deploy.jar - fi - # release.war is a symlink. We want an actual file so that docker copy works right. - cp bazel-bin/release.war release.war + {{ bazelisk_executable }} \ + build \ + --spawn_strategy=standalone \ + --genrule_strategy=standalone \ + {{ bazelisk_targets|join(' ') }} args: executable: /bin/bash chdir: "{{ zuul_work_dir }}"