Skip to content

Using Jib to push Images to Github

Create a Github Personal Access Token

Validate Account via docker login

# export CR_PAT=<YOUR-TOKEN>
# echo $CR_PAT | /usr/bin/docker login ghcr.io -u USERNAME --password-stdin
  WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
  Configure a credential helper to remove this warning. See
  https://docs.docker.com/engine/reference/commandline/login/#credentials-store

  Login Succeeded

Validate Github Connectivity with Docker

# docker pull hello-world
  Using default tag: latest
  latest: Pulling from library/hello-world
  Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
  Status: Downloaded newer image for hello-world:latest
  docker.io/library/hello-world:latest

# docker images hello-world
  REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
  hello-world   latest    feb5d9fea6a5   8 weeks ago   13.3kB
# docker tag hello-world ghcr.io/hhutzler/hello-world-new

# docker images  ghcr.io/hhutzler/hello-world-new
  REPOSITORY                         TAG       IMAGE ID       CREATED       SIZE
  ghcr.io/hhutzler/hello-world-new   latest    feb5d9fea6a5   8 weeks ago   13.3kB

# docker push ghcr.io/hhutzler/hello-world-new
  Using default tag: latest
  The push refers to repository [ghcr.io/hhutzler/hello-world-new]
  e07ee1baac5f: Mounted from hhutzler/hello-world2
  latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525

Use Jib to push Images to our Githup Repo

Prerequisites

  • Successfull docker login to Github Repo ghcr.io
  • Use -Djib.to.auth.username=hhutzler to specifiy Github Account
  • Without -Djib.to.auth.password switch docker login data will be used
  • If using -Djib.to.auth.password=xx use the Github Personal Access Token for Login
  • Docker logins are captured in ~/.docker/config.json
Download Google Sample:
# git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
# cd java-docs-samples/run/helloworld

Push Image:
# mvn  compile com.google.cloud.tools:jib-maven-plugin:3.1.4:build  -Dimage=ghcr.io/hhutzler/hello-world  -Djib.to.auth.username=hhutzler
..
  [INFO] Containerizing application to ghcr.io/hhutzler/hello-world...
  [WARNING] Base image 'adoptopenjdk:11-jre' does not use a specific image digest - build may not be reproducible
  [INFO] Using credentials from Docker config (/root/.docker/config.json) for ghcr.io/hhutzler/hello-world
  [INFO] The base image requires auth. Trying again for adoptopenjdk:11-jre...
  [INFO] Using base image with digest: sha256:ad6431b2e2a6f8016aa6d79c3f588783af9fdc06cafe131fd0d3faf560914b13
  [INFO]
  [INFO] Container entrypoint set to [java, -cp, @/app/jib-classpath-file, com.example.helloworld.HelloworldApplication]
  [INFO]
  [INFO] Built and pushed image as ghcr.io/hhutzler/hello-world
  [INFO] Executing tasks:
  [INFO] [============================  ] 91.7% complete
  [INFO] > launching layer pushers
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time:  7.408 s
  [INFO] Finished at: 2021-11-20T17:43:14+01:00
  [INFO] ------------------------------------------------------------------------

Validate Image Status on Github

  • Image hello-world should be uploaded to your Github Account

Published inQuarkus

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *