Can anybody point me to a python example of automa...
# python
p
Can anybody point me to a python example of automating building a docker image locally then pushing to ECR like this one? https://www.pulumi.com/blog/managing-containers-on-aws-with-pulumi/. I don’t see a way to do that in the aws_pulumi python API docs
f
this is for gcr but the docker code from the docker-build-push-gcr folder should work similarly
that’s typescript though simple smile
c
does this get you started?
Copy code
import docker
DOCKER_TAG = config.get("dockerTag")
DOCKER_REPO_URI = PREFIX + "acr" + ".<http://azurecr.io|azurecr.io>" + DOCKER_TAG
# docker client
dockerclient = docker.from_env()

if pulumi.runtime.is_dry_run() == False:
    image, log = dockerclient.images.build(
        path="./",
        tag=PREFIX + "acr" + DOCKER_TAG
    )
    for line in log:
        print(line)
def docker_login_and_push(args):
    dockerclient.login(
            registry=args[0],
            username=args[1],
            password=args[2]
        )
    for line in dockerclient.images.push(repository=DOCKER_REPO_URI, stream=True, decode=True):
        print(line)

# Push docker image to ACR
Output.all(acr.login_server, acr.admin_username,
        acr.admin_password).apply(docker_login_and_push)
This is ACR though, not ECR.