Errors in populateECRCredentials task

Issue #10 invalid
sumit.khanna@tmsw.com created an issue

When I attempt to run a gradle dockerBuild or gradle dockerPushImage, I get the following error:

# set is fish / export in bash

set -x  AWS_ACCESS_KEY_ID **REMOVED**
set -x AWS_SECRET_ACCESS_KEY **REMOVED**

gradle dockerPushImage

> Configure project : 
Reckoned version: 0.1.0-milestone.0.6+6b24c48eba16e42ed31bc35e1bc68fc98a0d2411


FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':populateECRCredentials'.
> No value has been specified for property 'registryUrl'.
> No value has been specified for property 'registryId'.

I've tried it both with the keys as environment variables and with gradle dockerPushImage -PawsAccessKeyId=$AWS_ACCESS_KEY_ID -PawsSecretAccessKey=$AWS_SECRET_ACCESS_KEY with the same error.

I've included my gradle configuration file below. I've tried changing the order of how I declare the plugins as well as where I declare the docker section. I'm digging through the plugin source code and am confused as to where it actually pulls the AWS environment variables.

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.bmuschko:gradle-docker-plugin:3.2.5'
  }
}

plugins {
  id 'scala'
  id 'application'
  id 'org.ajoberstar.grgit' version '2.1.1'
  id 'org.ajoberstar.reckon' version '0.4.0'
  id 'com.patdouble.awsecr' version '0.3.3'
}

reckon {
  normal = scopeFromProp()
  preRelease = stageFromProp('milestone', 'rc', 'final')
}

apply plugin: 'com.bmuschko.docker-java-application'
apply plugin: 'com.bmuschko.docker-remote-api'

ext {
  vertxVersion = '3.5.1'
  scalaVersion = '2.12'
}

repositories {
  mavenLocal()
  jcenter()
  maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
  compile "io.vertx:vertx-core:$vertxVersion"
  compile "io.vertx:vertx-web:$vertxVersion"
  compile 'ch.qos.logback:logback-classic:1.2.3'
  compile "io.vertx:vertx-lang-scala_$scalaVersion:$vertxVersion"
  compile "org.scala-lang:scala-library:${scalaVersion}.4"
  compile "com.typesafe:config:1.3.3"
}

sourceCompatibility = '1.8'
mainClassName = 'com.example.SampleService'

group = 'example'

docker {
  javaApplication {
    baseImage = 'java:openjdk-9-jre'
    maintainer = 'Example - iExample Team'
    ports = [8080]
  }
  registryCredentials {
    url = 'https://**removed**.dkr.ecr.us-east-1.amazonaws.com'
  }
}


run {
  args = ['run', mainClassName, "--launcher-class=io.vertx.core.Launcher"]
}

task wrapper(type: Wrapper) {
  gradleVersion = '4.0'
}

Comments (4)

  1. Patrick Double repo owner

    The credentials are found using the AWS SDK, so you won't see it in the plugin source code. The real issue is that the dockerPushImage hasn't been set with a tag that includes the ECR registry. This is how the gradle-docker-plugin works, you must specify the registry in the image tag for any of the docker tasks so that you can use multiple registries.

    Something like:

    docker {
      javaApplication {
        tag = '**removed**.dkr.ecr.us-east-1.amazonaws.com/my-app:latest'
      }
    }
    
  2. sumit.khanna@tmsw.com reporter

    Instead of making this invalid, shouldn't this be added to the documentation, or at the very least, a better error message given?

  3. Patrick Double repo owner

    There is documentation in README.md. Can you review starting at the following paragraph:

    Then set the Docker registry to your ECR URL. The URL is given by the AWS ECR console. Note that this clause is defined by the gradle-docker-plugin. Neither username nor password should be set, the gradle-aws-ecr-plugin will handle that.

    There was also a change released in 0.4.0 that doesn't fail the PopulateECRCredentials task if no ECR registry is configured, to support conditional use of ECR.

  4. Log in to comment