I am trying to write a tool to automatically push docker image into aws ECR.
I am trying to push a docker image into aws ECR using aws golang sdk. was trying to follow this documentation https://docs.aws.amazon.com/sdk-for-go/api/service/ecr/#ECR.PutImage
but no clue how to make ImageManifest object https://docs.aws.amazon.com/sdk-for-go/api/service/ecr/#PutImageInput Help is very much appreciated.
The documentation clearly says:
This operation is used by the Amazon ECR proxy, and it is not intended for general use by customers for pulling and pushing images. In most cases, you should use the docker CLI to pull, tag, and push images.
Instead doing that way I will recommend you to use exec
Go package and implement the exec commands directly in your build machine.
You can do something like this:
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
name := "docker"
args := []string{"push", "registry/name:tag"}
cmd := exec.Command(name, args...)
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println("done")
}
I took this example from the this blog https://nathanleclaire.com/blog/2014/12/29/shelled-out-commands-in-golang/
I hope you can have this info useful