Hi everyone :wave: I'm new to pulumi and I'm curre...
# general
a
Hi everyone 👋 I'm new to pulumi and I'm currently checking out https://www.pulumi.com/registry/packages/docker-build/api-docs/image
Copy code
provider = docker_build.Provider("test-provider", host="unix:///var/run/docker.sock")
image = docker_build.Image(
    "test-image",
    context=dict(location="."),
    dockerfile=dict(location="./Dockerfile"),
    platforms=[docker_build.Platform.LINUX_AMD64],
    tags=["test-image"],
    push=False,
    opts=pulumi.ResourceOptions(provider=provider),
    exports=[{"docker": {'tar': True}}],
)
Can someone advise me on how to properly configure the inputs to
docker_build.Image
? Especially the
exports
parameter, if I don't set it, the output
digest
is an empty string. I am just interested in a simple docker build, nothing fancy. And by the way, do you recommend building images through pulumi at all?
f
Hey! I may be able to help here. In the docs it says that
digest
is "A SHA256 digest of the image if it was exported to a registry or elsewhere. Empty if the image was not exported." So maybe your image is not being exported properly. And perhaps that's because
exports
parameter is incorrect. Are you just trying to build an image locally? If so I think you don't even need to provide
exports
and Pulumi will default to building and saving the image locally. As for your second question, I think it depends on your workflow. If you want to control every aspect of a container lifecycle through IaC then it's probably a good idea to build images with Pulumi, deploy them as containers with Pulumi, and so on.
m
Hi @fast-ram-96156 I am using pulumi.docker.image but I have a serious problem with it. There is no import option for it so I am forced to build my image everytime that I run pulumi up. Is there anyway to solve this issue?
a
Hey @fast-ram-96156, I am indeed just trying to build an image locally, so I have no need for exporting, but I still need the digest in order to pass it to
docker.Container
😅 Anyhow I'm just testing locally for now, I will in the future export the built images to a repository, which I guess will solve my problem. As for my second question, I'm working on a small scale project where I have the opportunity to revamp the whole architecture. I will use pulumi to build the images then! Thanks for your help 😉
m
I had an illuminating discussion with a nice folk here on slack the other day. Pulumi is a great tool but one has to understand the philosophy behind it, Infrastructure as Code. What is inside a container isn't the business of the infrastructure so image creation is the responsibility of pipeline. It even makes it easier in the pipeline to do path filtering and rebuild and push the only images of those projects that have changes.