Fix branch checkout in the build Docker image, refs #21089
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 6 Dec 2023 22:54:53 +0000 (17:54 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 7 Dec 2023 15:21:46 +0000 (10:21 -0500)
Previously it would always check out the remote HEAD and not the
intended version that was going to be built, which causes problems
when the build environment diverges.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

build/package-build-dockerfiles/centos7/Dockerfile
build/package-build-dockerfiles/debian10/Dockerfile
build/package-build-dockerfiles/debian11/Dockerfile
build/package-build-dockerfiles/rocky8/Dockerfile
build/package-build-dockerfiles/ubuntu1804/Dockerfile
build/package-build-dockerfiles/ubuntu2004/Dockerfile
build/run-build-packages-one-target.sh

index a423819dd0a645368201ff3a1515c1ed5b862e5a..3c73ad9222e4c1f8e0098ba512b03175473e76d9 100644 (file)
@@ -7,6 +7,7 @@ ARG BRANCH
 ARG GOVERSION
 
 FROM centos:7 as build_x86_64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
@@ -18,6 +19,7 @@ ONBUILD RUN npm install -g yarn
 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
 
 FROM centos:7 as build_aarch64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
@@ -75,7 +77,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index c0349aa798101a0cc2cdd3938a894218f1a661e2..d8b3d17b41a0f978d97a6d1ce40e76681897662f 100644 (file)
@@ -8,6 +8,7 @@ ARG GOVERSION
 
 ## dont use debian:10 here since the word 'buster' is used for rvm precompiled binaries
 FROM debian:buster as build_x86_64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
@@ -20,6 +21,7 @@ ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
 # No cross compilation support for debian10 because of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477
 
 FROM debian:buster as build_aarch64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
@@ -62,7 +64,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index cccf8930d2073b50ce7eca615a777d7ae8fb1fa9..be818587b322ee6c2492a4de25fd55b48a540463 100644 (file)
@@ -9,6 +9,7 @@ ARG GOVERSION
 ## dont use debian:11 here since the word 'bullseye' is used for rvm precompiled binaries
 FROM debian:bullseye as build_x86_64
 # Install go
+ONBUILD ARG BRANCH
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
@@ -26,6 +27,7 @@ ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediat
 
 FROM debian:bullseye as build_aarch64
 # Install go
+ONBUILD ARG BRANCH
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
 ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
@@ -68,7 +70,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index 8bc9b0b79d4aded3644ed3000f0c68f1951bbe19..a1bf643f9a52ef54651d9c34216134d362e0b766 100644 (file)
@@ -7,6 +7,7 @@ ARG BRANCH
 ARG GOVERSION
 
 FROM rockylinux:8.6-minimal as build_x86_64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
@@ -18,6 +19,7 @@ ONBUILD RUN npm install -g yarn
 ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
 
 FROM rockylinux:8.6-minimal as build_aarch64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
@@ -87,7 +89,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index 304e2c925b9b61024a8bb6c73b5625619a6718bb..4754adbc2d39502e9c1d883737c094918523981b 100644 (file)
@@ -7,6 +7,7 @@ ARG BRANCH
 ARG GOVERSION
 
 FROM ubuntu:bionic as build_x86_64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
@@ -19,6 +20,7 @@ ONBUILD RUN ln -sf /usr/local/node-v12.22.12-linux-x64/bin/* /usr/local/bin/
 # No cross compilation support for ubuntu1804 because of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477
 
 FROM ubuntu:bionic as build_aarch64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
@@ -61,7 +63,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index f85d5d696667759b4f877778c259b12ff0b8654d..a21f8a2ab9e641f62e7014582ec727b94ad2f41e 100644 (file)
@@ -7,6 +7,7 @@ ARG BRANCH
 ARG GOVERSION
 
 FROM ubuntu:focal as build_x86_64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-amd64.tar.gz /usr/local/
@@ -30,6 +31,7 @@ ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediat
 # ubuntu2204 will have the fix introduced in debian11.
 
 FROM ubuntu:focal as build_aarch64
+ONBUILD ARG BRANCH
 # Install go
 ONBUILD ARG GOVERSION
 ONBUILD ADD generated/go${GOVERSION}.linux-arm64.tar.gz /usr/local/
@@ -72,7 +74,7 @@ ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 # Preseed the go module cache and the ruby gems, using the currently checked
 # out branch of the source tree. This avoids potential compatibility issues
 # between the version of Ruby and certain gems.
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+RUN git clone git://git.arvados.org/arvados.git /tmp/arvados && \
     cd /tmp/arvados && \
     if [[ -n "${BRANCH}" ]]; then git checkout ${BRANCH}; fi && \
     cd /tmp/arvados/services/api && \
index 1ba06fd3688828897efee4d531eee5ea06f7f51e..12ed10bcb86ce5e62763fdc2fa7a5f27cd9f3ab0 100755 (executable)
@@ -203,7 +203,7 @@ if [[ "$SKIP_DOCKER_BUILD" != 1 ]] ; then
     cd $TARGET
     time docker build --tag "$IMAGE" \
         --build-arg HOSTTYPE=$HOSTTYPE \
-        --build-arg BRANCH=$(git rev-parse --abbrev-ref HEAD) \
+        --build-arg BRANCH=$(git rev-parse HEAD) \
         --build-arg GOVERSION=$GOVERSION --no-cache .
     popd
 fi