question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jib.to.image push to multiple repositories

See original GitHub issue

Environment:

  • Jib version: 1.1.2
  • Build tool: Gradle v1.1.2
  • OS: MacOS

Description of the issue:

Seeking a way to push the same image to multiple image repositories. We have a need where we need to host our images in both DockerHub and ECR, the documentation doesn’t make any reference to if this is possible. If it is in-fact possible, if someone can explain it here, I’d be happy to help update the documentation for the gradle plugin as needed.

Expected behavior:

Allow a means to specify multiple jib.to.image values, such as via a comma separated list, with the expectation that each image provided will be pushed to the correct docker respository.

Steps to reproduce:

  1. Create a container repo on dockerhub and ECR
  2. Try to push one docker container to both repo’s in one build.

jib-gradle-plugin Configuration:

jib {
	to {
		tags ['latest', 'develop']
		// one possibility:
                image "organization/repo, id.dkr.ecr.us-west-2.amazonaws.com/repo"
		// second possibility:
		image ['organization/repo', 'id.dkr.ecr.us-west-2.amazonaws.com/repo']
    }
}       

Log output:

Caused by: com.google.cloud.tools.jib.image.InvalidImageReferenceException: Invalid image reference: org/repo,id.dkr.ecr.us-east-1.amazonaws.com/repo

— OR —

  • What went wrong: Script compilation errors:
  Line 133:         image=listOf("org/repo","id.dkr.ecr.us-east-1.amazonaws.com/repo")
                          ^ Type mismatch: inferred type is List<String> but String? was expected

My log output is from a kotlin gradle buildscript, but I think the concepts apply no matter the buildscript language - there does not appear to be a way to specify 2 image locations to be able to push an image to 2 image repos via one build.

There is a workaround specified here but it feels somewhat un-natural and so I wonder if this tool should support this use case?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
OneCricketeercommented, Feb 27, 2020

Why not loop and push in a fashion similar to this?

buildCmd -Djib.to.image=foo
buildCmd -Djib.to.image=bar
1reaction
chanseokohcommented, Jan 4, 2022

I wouldn’t worry too much about running Jib multiple times. Everything built for an image is cached and reused (thanks to the strong reproducibility of Jib), so subsequent runs will be no-op regarding building something.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dockerizing Java Apps using Jib - Baeldung
Jib is an open-source Java tool maintained by Google for building Docker images of Java applications. It simplifies containerization since with ...
Read more >
Building Java container images using Jib - Snyk
In this article, we will look at Jib, a 100% Java-based tool for Java developers to build highly optimized images for their Java...
Read more >
Building Java containers with Jib - Google Cloud
Jib handles all steps of packaging your application into a container image. ... Build and push the image to a container registry: mvn...
Read more >
Multiple tags for a Docker image built by Google Jib and Maven?
Using the jib-maven-plugin I'd like to build an image with mulitple tags. While mvn jib:build basically works fine, it "only" tags the image...
Read more >
How to Publish Docker Images on a Private Nexus Repository ...
Jib is a framework to build and compile Docker images with and without the Docker daemon available on system. There are two plugins...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found