Skip to content

Commit 353f577

Browse files
authored
chore(bq jdbc): fix docker environment commands (#12107)
1 parent 618e734 commit 353f577

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
FROM gcr.io/cloud-devrel-public-resources/java11
2-
2+
ARG BRANCH=main
33
ENV JDBC_DOCKER_ENV=true
4-
RUN apt-get update && apt-get install -y zip && rm -rf /var/lib/apt/lists/*
5-
6-
RUN mkdir /tst
7-
COPY ./pom.xml /src/pom.xml
8-
COPY ./java.header /src/java.header
9-
COPY ./license-checks.xml /src/license-checks.xml
10-
COPY ./google-cloud-bigquery-jdbc/pom.xml /src/google-cloud-bigquery-jdbc/pom.xml
114

12-
COPY ./google-cloud-bigquery /src/google-cloud-bigquery
13-
COPY ./google-cloud-bigquery-bom /src/google-cloud-bigquery-bom
5+
# Changes to `pom.xml` will trigger re-sync
6+
COPY pom.xml /src/pom.xml
147

8+
# Doing it via single command, so layer contains only installed moduled vs full repo
9+
# Copy from local repo is taking forever. Doing via git clone will keep dependencies ~up to date.
10+
# It will fail on old branches forcing to sync to latest main branch.
11+
RUN bash -c " \
12+
mkdir /git \
13+
&& cd /git \
14+
&& git clone -b ${BRANCH} --depth 1 --single-branch https://github.com/googleapis/google-cloud-java.git \
15+
&& cd /git/google-cloud-java \
16+
&& source .kokoro/common.sh \
17+
&& install_modules java-bigquery \
18+
&& rm -rf /git"
1519

20+
# This will ensure all deps are present
1621
WORKDIR /src
17-
RUN mvn install -DskipTests
18-
19-
WORKDIR /src/google-cloud-bigquery-jdbc
22+
RUN mvn install
2023

2124
ENTRYPOINT []

java-bigquery/google-cloud-bigquery-jdbc/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
SHELL := /bin/bash # Default 'sh' doesn't support 'source'
2+
BUILD_BRANCH=main
13
CONTAINER_NAME=jdbc
24
PACKAGE_DESTINATION=$(PWD)/drivers
3-
SRC="$(PWD)/.."
5+
SRC="$(PWD)"
46
skipSurefire ?= true
57

68
# no indendation for ifndef\endif due to their evaluation before execution
@@ -10,7 +12,9 @@ ifndef GOOGLE_APPLICATION_CREDENTIALS
1012
endif
1113

1214
install:
13-
mvn clean install
15+
cd "$(PWD)/../.." && \
16+
source ".kokoro/common.sh" && \
17+
install_modules java-bigquery
1418

1519
clean:
1620
mvn clean
@@ -77,7 +81,7 @@ generate-dependency-list:
7781
$(CONTAINER_NAME) $(args)
7882

7983
docker-build:
80-
docker build -t $(CONTAINER_NAME) -f Dockerfile ..
84+
docker build -t $(CONTAINER_NAME) -f Dockerfile --build-arg BRANCH=${BUILD_BRANCH} $(SRC)
8185

8286
docker-session:
8387
$(MAKE) .docker-run args="bash"

java-bigquery/google-cloud-bigquery-jdbc/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@
366366
<!-- Ensure it doesn't conflict with local build directories -->
367367
<directory>/mvn/test-target</directory>
368368
</build>
369+
<properties>
370+
<!-- Disable to avoid bringing license-checks to docker env -->
371+
<checkstyle.skip>true</checkstyle.skip>
372+
</properties>
369373
</profile>
370374
</profiles>
371375
</project>

0 commit comments

Comments
 (0)