From 7adb377f98d48d8787f0d0e7c32a06ae3bae12f4 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 18 Mar 2026 00:45:47 +0000 Subject: [PATCH 1/2] chore(bq jdbc): fix docker environment commands --- .../google-cloud-bigquery-jdbc/Dockerfile | 27 ++++++++++--------- .../google-cloud-bigquery-jdbc/Makefile | 9 ++++--- .../google-cloud-bigquery-jdbc/pom.xml | 4 +++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile b/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile index f88cc5a4bc90..16ae049feb18 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile +++ b/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile @@ -1,21 +1,24 @@ FROM gcr.io/cloud-devrel-public-resources/java11 ENV JDBC_DOCKER_ENV=true -RUN apt-get update && apt-get install -y zip && rm -rf /var/lib/apt/lists/* -RUN mkdir /tst -COPY ./pom.xml /src/pom.xml -COPY ./java.header /src/java.header -COPY ./license-checks.xml /src/license-checks.xml -COPY ./google-cloud-bigquery-jdbc/pom.xml /src/google-cloud-bigquery-jdbc/pom.xml - -COPY ./google-cloud-bigquery /src/google-cloud-bigquery -COPY ./google-cloud-bigquery-bom /src/google-cloud-bigquery-bom +# Changes to `pom.xml` will trigger re-sync +COPY pom.xml /src/pom.xml +# Doing it via single command, so layer contains only installed moduled vs full repo +# Copy from local repo is taking forever. Doing via git clone will keep dependencies ~up to date. +# It will fail on old branches forcing to sync to latest main branch. +RUN bash -c " \ + mkdir /git \ + && cd /git \ + && git clone https://github.com/googleapis/google-cloud-java.git \ + && cd /git/google-cloud-java \ + && source .kokoro/common.sh \ + && install_modules java-bigquery \ + && rm -rf /git" +# This will ensure all deps are present WORKDIR /src -RUN mvn install -DskipTests - -WORKDIR /src/google-cloud-bigquery-jdbc +RUN mvn install ENTRYPOINT [] diff --git a/java-bigquery/google-cloud-bigquery-jdbc/Makefile b/java-bigquery/google-cloud-bigquery-jdbc/Makefile index 6adcb7e8a48d..285bd8ef1144 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/Makefile +++ b/java-bigquery/google-cloud-bigquery-jdbc/Makefile @@ -1,6 +1,7 @@ +SHELL := /bin/bash # Default 'sh' doesn't support 'source' CONTAINER_NAME=jdbc PACKAGE_DESTINATION=$(PWD)/drivers -SRC="$(PWD)/.." +SRC="$(PWD)" skipSurefire ?= true # no indendation for ifndef\endif due to their evaluation before execution @@ -10,7 +11,9 @@ ifndef GOOGLE_APPLICATION_CREDENTIALS endif install: - mvn clean install + cd "$(PWD)/../.." && \ + source ".kokoro/common.sh" && \ + install_modules java-bigquery clean: mvn clean @@ -77,7 +80,7 @@ generate-dependency-list: $(CONTAINER_NAME) $(args) docker-build: - docker build -t $(CONTAINER_NAME) -f Dockerfile .. + docker build -t $(CONTAINER_NAME) -f Dockerfile $(SRC) docker-session: $(MAKE) .docker-run args="bash" diff --git a/java-bigquery/google-cloud-bigquery-jdbc/pom.xml b/java-bigquery/google-cloud-bigquery-jdbc/pom.xml index 36ef039e7851..afc15c9322d5 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/pom.xml +++ b/java-bigquery/google-cloud-bigquery-jdbc/pom.xml @@ -341,6 +341,10 @@ /mvn/test-target + + + true + \ No newline at end of file From 88455588124aa77fad5479b130fadacb78e74c38 Mon Sep 17 00:00:00 2001 From: Kirill Logachev Date: Wed, 18 Mar 2026 23:15:52 +0000 Subject: [PATCH 2/2] Allow non-main branch & don't clone entire repo --- java-bigquery/google-cloud-bigquery-jdbc/Dockerfile | 4 ++-- java-bigquery/google-cloud-bigquery-jdbc/Makefile | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile b/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile index 16ae049feb18..374a1c6a82fb 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile +++ b/java-bigquery/google-cloud-bigquery-jdbc/Dockerfile @@ -1,5 +1,5 @@ FROM gcr.io/cloud-devrel-public-resources/java11 - +ARG BRANCH=main ENV JDBC_DOCKER_ENV=true # Changes to `pom.xml` will trigger re-sync @@ -11,7 +11,7 @@ COPY pom.xml /src/pom.xml RUN bash -c " \ mkdir /git \ && cd /git \ - && git clone https://github.com/googleapis/google-cloud-java.git \ + && git clone -b ${BRANCH} --depth 1 --single-branch https://github.com/googleapis/google-cloud-java.git \ && cd /git/google-cloud-java \ && source .kokoro/common.sh \ && install_modules java-bigquery \ diff --git a/java-bigquery/google-cloud-bigquery-jdbc/Makefile b/java-bigquery/google-cloud-bigquery-jdbc/Makefile index 285bd8ef1144..4f54e7a3698f 100644 --- a/java-bigquery/google-cloud-bigquery-jdbc/Makefile +++ b/java-bigquery/google-cloud-bigquery-jdbc/Makefile @@ -1,4 +1,5 @@ SHELL := /bin/bash # Default 'sh' doesn't support 'source' +BUILD_BRANCH=main CONTAINER_NAME=jdbc PACKAGE_DESTINATION=$(PWD)/drivers SRC="$(PWD)" @@ -80,7 +81,7 @@ generate-dependency-list: $(CONTAINER_NAME) $(args) docker-build: - docker build -t $(CONTAINER_NAME) -f Dockerfile $(SRC) + docker build -t $(CONTAINER_NAME) -f Dockerfile --build-arg BRANCH=${BUILD_BRANCH} $(SRC) docker-session: $(MAKE) .docker-run args="bash"