sjednac / sbt-ecr

An SBT plugin for managing Docker images within Amazon ECR.
Other
52 stars 25 forks source link

Cannot push image #2

Closed dmytro closed 7 years ago

dmytro commented 7 years ago

I'm using version 0.3.0 of the sbt-ecr plugin, but I'm not able to push the image. Two other commands ecr:login and ecr:createRepository work OK, but push apparently does nothing.

I am using Docker 1.13 on a Mac, and my suspicion that tagging https://github.com/sbilinski/sbt-ecr/blob/master/src/main/scala/sbtecr/EcrPlugin.scala#L57) step does not work. I am not a Scala person, but if I understand this code correctly, it should add tag to the the image with the registry name prepended.

When I run docker images after ecr:push image is not tagged:

$ docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimage                                             latest              75e222321012        4 minutes ago       257 MB
<aws_account>.dkr.ecr.us-east-1.amazonaws.com/java  latest              d5c4c8395ef9        3 months ago        174 MB

This is my configuration:

name := "myimage"
version := "latest"

packageName in Docker := "myimage"
version     in Docker := version.value

dockerBaseImage := "<aws_account>.dkr.ecr.us-east-1.amazonaws.com/java:latest"
dockerExposedPorts := Seq(9000)

import com.amazonaws.regions.{Region, Regions}

region           in ecr := Region.getRegion(Regions.US_EAST_1)
repositoryName   in ecr := (packageName in Docker).value
localDockerImage in ecr := (packageName in Docker).value + ":" + (version in Docker).value

addCommandAlias("publish", ";clean;compile;docker:publishLocal;ecr:createRepository;ecr:login;ecr:push")

And docker version:

$ docker version                                                                                                                                                                                    U feature/build_with_jenkins:exco-corp-web/. 12:47:20
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Wed Jan 18 16:20:26 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Wed Jan 18 16:20:26 2017
 OS/Arch:      linux/amd64
 Experimental: true
sjednac commented 7 years ago

Are you sure that the docker:publishLocal command succeed? Could you post sbt output and/or try running the printed Docker command manually?

Since the image depends on another image from Amazon ECR, you'll need to ecr:login before the image is built - try executing ecr:login before docker:publishLocal.

dmytro commented 7 years ago

Hi,

To answer your questions:

Here's full sbt output:

[dmytro@Svaroh-2 my-project]$ docker images | grep myproject
[dmytro@Svaroh-2 my-project]$ sbt publish
[info] Loading project definition from /Users/dmytro/my-project/project
[info] Set current project to myproject (in build file:/Users/dmytro/my-project/)
[success] Total time: 0 s, completed Jan 31, 2017 5:41:29 PM
[info] Updating {file:/Users/dmytro/my-project/}my-project...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /Users/dmytro/my-project/target/scala-2.10/classes...
[success] Total time: 8 s, completed Jan 31, 2017 5:41:37 PM
[info] Packaging /Users/dmytro/my-project/target/scala-2.10/myproject_2.10-latest-sources.jar ...
[info] Done packaging.
[info] Wrote /Users/dmytro/my-project/target/scala-2.10/myproject_2.10-latest.pom
[info] Main Scala API documentation to /Users/dmytro/my-project/target/scala-2.10/api...
[info] Packaging /Users/dmytro/my-project/target/scala-2.10/myproject_2.10-latest.jar ...
[info] Done packaging.
model contains 19 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /Users/dmytro/my-project/target/scala-2.10/myproject_2.10-latest-javadoc.jar ...
[info] Done packaging.
[info] Sending build context to Docker daemon 41.85 MB
[info] Step 1/8 : FROM <AWS_ACCOUNT>.dkr.ecr.us-east-1.amazonaws.com/java:latest
[info]  ---> d5c4c8395ef9
[info] Step 2/8 : WORKDIR /opt/docker
[info]  ---> 2d3ebf835c83
[info] Removing intermediate container 1ebe8d921b0d
[info] Step 3/8 : ADD opt /opt
[info]  ---> 646798f0a0d2
[info] Removing intermediate container 6e1d6291cb18
[info] Step 4/8 : RUN chown -R daemon:daemon .
[info]  ---> Running in a7885de1e640
[info]  ---> 590bfa522f25
[info] Removing intermediate container a7885de1e640
[info] Step 5/8 : EXPOSE 9000
[info]  ---> Running in ce2ad46ec38c
[info]  ---> 92a183055821
[info] Removing intermediate container ce2ad46ec38c
[info] Step 6/8 : USER daemon
[info]  ---> Running in 48df9e265abc
[info]  ---> 9919ad6fa6cf
[info] Removing intermediate container 48df9e265abc
[info] Step 7/8 : ENTRYPOINT bin/myproject
[info]  ---> Running in 492053822e07
[info]  ---> 7cd410276395
[info] Removing intermediate container 492053822e07
[info] Step 8/8 : CMD
[info]  ---> Running in 521ec42136eb
[info]  ---> 9da9cf4d5a9f
[info] Removing intermediate container 521ec42136eb
[info] Successfully built 9da9cf4d5a9f
[info] Built image myproject:latest
[success] Total time: 12 s, completed Jan 31, 2017 5:41:49 PM
[info] Repository exists: us-east-1/myproject
[success] Total time: 2 s, completed Jan 31, 2017 5:41:50 PM
[info] AWS account id: <AWS_ACCOUNT>
Flag --email has been deprecated, will be removed in 1.14.
Login Succeeded
[success] Total time: 4 s, completed Jan 31, 2017 5:41:54 PM
[success] Total time: 0 s, completed Jan 31, 2017 5:41:54 PM
[dmytro@Svaroh-2 my-project]$ docker images | grep myproject
myproject                                                         latest              9da9cf4d5a9f        12 seconds ago      257 MB
[dmytro@Svaroh-2 my-project]$
sjednac commented 7 years ago

Thanks for the detailed description. Unfortunately, I'm unable to reproduce this issue in my local environment.

Few things that come to mind:

dmytro commented 7 years ago

Sorry for the confusion. It was my problem, I was using sbt 0.13.13, operator <<= is deprecated and there was a syntax error in push in ecr <<= (push in ecr) dependsOn (publishLocal in Docker) line.