Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 1.51 KB

google-cloud-build.md

File metadata and controls

33 lines (27 loc) · 1.51 KB

Jib on Google Cloud Build

You can use Jib on Google Cloud Build in a simple step:

steps:
  - name: 'gcr.io/cloud-builders/javac:8'
    entrypoint: './gradlew'
    args: ['--console=plain', '--no-daemon', ':server:jib', '-Djib.to.image=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']

Any Java container can be used for building, not only the gcr.io/cloud-builders/javac:* (from gcr.io/cloud-builders/javac), for example with Temurin's:

steps:
  - name: 'docker.io/library/eclipse-temurin:21'
    entrypoint: './gradlew'
    args: ['--console=plain', '--no-daemon', ':server:jib', '-Djib.to.image=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA']

To use Google "Distroless" Container Images to build with Jib on Google Cloud Build, and avoid running into Step #1: standard_init_linux.go:228: exec user process caused: no such file or directory errors (because Google's distroless containers are based on busybox), you have to do something like this:

steps:
  - name: 'gcr.io/distroless/java17-debian11:debug'
    entrypoint: '/busybox/sh'
    args:
      - -c
      - |
        ln -s /busybox/sh /bin/sh
        ln -s /busybox/env /usr/bin/env
        /workspace/gradlew --console=plain --no-daemon --gradle-user-home=/home/.gradle :server:jib -Djib.to.image=gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA