0

I have a multimodule project that I am trying to use gradle 7.5.1 and jib to build and deploy each service artifact to ECR.

I have a ~/.docker/config.json file

{
  "credsStore": "desktop"
}
{
        "credHelpers": {
                "public.ecr.aws": "ecr-login",
                "xxxxxxx.dkr.ecr.us-east-1.amazonaws.com": "ecr-login"
        }
}

and my AWS keys are in ~/.aws/credentials

Each of my modules has a settings.gradle that defines the rootProject.name to be the service (artifactId), as well as the plugin 'maven-publish'.

In my main project I have a build.gradle:

plugins {
    id 'java'
    id 'groovy'
    id 'com.google.cloud.tools.jib' version '3.3.0'
    id 'maven-publish'
} 
..
jib {
    from {
        image = 'azul/zulu-openjdk:17-jre'
    }
    to {
        image = 'xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${rootProject.name}'
        // I have also tried image = 'xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${artifactId}'
    }
}

When I try to build them via gradle jib I get the following error:

> Task :jib FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jib'.
> Invalid image reference xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/${rootProject.name}, perhaps you should check that the reference is formatted correctly according to https://docs.docker.com/engine/reference/commandline/tag/#extended-description
  For example, slash-separated name components cannot have uppercase letters

The stacktrace also mentioned the invalid reference.

I am following several tutorials and the Google jib documentation, but I do not see what I am doing wrong - anyone else know?

sonoerin
  • 5,015
  • 23
  • 75
  • 132

1 Answers1

1

Use double quotes instead of single quotes to make Gradle expand properties.

Chanseok Oh
  • 3,920
  • 4
  • 23
  • 63
  • Thank you, that got me past that error and onto one that the artifact:latest not found. This makes sense as its the first build. My understanding is if not found, then the docker image is created and deployed to the appropriate repository? – sonoerin Sep 26 '22 at 20:18
  • In some sense, every asset that comprises the image is created and stores somewhere locally. And only those assets necessary (missing in the target registry, AWS ECR in your case) are uploaded, ensuring that a complete image is there. Thus it is possible that nothing is uploaded if everything is already there. – Chanseok Oh Sep 27 '22 at 22:29
  • the ECR was empty until I explicitly use the docker copy to move it from local to there. I don't know what I am doing wrong - will try to figure it out when I have more time. thanks anyway – sonoerin Sep 28 '22 at 01:13