Skip to content

Commit 2d86463

Browse files
authored
ci: java container build to use go.mod at the root (#2679)
After the migration from sdk-platform-java to librarian, we start to use the go.mod at the root of the librarian repository. This is the same setup as the automation's dispatcher ( infra/dispatcher/Dockerfile). I confirmed that the Dockerfile works: ``` suztomo@suztomo:~/librarian$ docker build -f internal/container/java/Dockerfile . [+] Building 21.1s (14/14) FINISHED docker:default ...(omit)... => [builder 6/7] COPY . . 0.7s => [builder 7/7] RUN CGO_ENABLED=0 GOOS=linux go build -v -o /librariangen ./internal/container/java 14.0s => [stage-1 2/2] COPY --from=builder /librariangen /usr/local/bin/librariangen 0.1s => exporting to image 0.1s => => exporting layers 0.0s => => writing image sha256:4dd4813eeea24c268d638011d961641a11d31014b5abbc399b20346602424fae ```
1 parent 09dc53f commit 2d86463

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

internal/container/java/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ WORKDIR /src
5050
COPY . .
5151

5252
# Build the librariangen binary.
53-
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /librariangen .
53+
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /librariangen ./internal/container/java
5454

5555
# --- Final Stage ---
5656
# This stage creates the final, minimal image with the compiled binary and
@@ -62,4 +62,4 @@ COPY --from=builder /librariangen /usr/local/bin/librariangen
6262

6363
# Set the entrypoint for the container to run the compiled librariangen.
6464
# The Librarian will provide commands like 'generate' as arguments.
65-
ENTRYPOINT [ "/usr/local/bin/librariangen" ]
65+
ENTRYPOINT [ "/usr/local/bin/librariangen" ]

internal/container/java/cloudbuild-exitgate.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ steps:
2323
- |
2424
docker pull us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-dev/librarian-java:latest || exit 0
2525
- name: gcr.io/cloud-builders/docker
26-
args: ["build", "--cache-from", "us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-dev/librarian-java:latest", "-t", "us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-dev/librarian-java:latest", "-f", "Dockerfile", "."]
27-
dir: internal/container/java
26+
args:
27+
- "build"
28+
- "--cache-from"
29+
- "us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-dev/librarian-java:latest"
30+
- "-t"
31+
- "us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-dev/librarian-java:latest"
32+
- "-f"
33+
- "internal/container/java/Dockerfile"
34+
- "."
2835
options:
2936
machineType: 'E2_HIGHCPU_8'
3037
requestedVerifyOption: VERIFIED # For provenance attestation generation

0 commit comments

Comments
 (0)