Hi Team, Is there a way to cache Pulumi stack reso...
# general
p
Hi Team, Is there a way to cache Pulumi stack resource creation instead of rebuilding the whole stack again.
c
Stack resources are stored in the pulumi state files. Can you clarify what sequence of commands you're attempting to optimise?
p
The pulumi up command when provisioning resources.
c
pulumi up
won't rebuild resources, unless you're using a weird Provider
p
I don't want it to build everything from scratch including the resource.
Ok.
Maybe my configuration is bad. Let me check.
c
What does
pulumi preview
tell you it intends on doing?
p
It wants to update the changes. Now my issue is that it rebouilds the docker images every time even if I have not updated the images configuration since I am usinf ECR and ECS.
I want to reduce the time takes for each subsequent build after the resources have been created but the time is the same.
c
I see. Personally I don't use the docker provider to build my images, I do that in a distinct CICD step.
p
PS: I am using Jenkins CI
Would you mind to share how you go about it?
c
Copy code
const myAppImage = new docker.Image("my-app-image", {
    build: {
        args: {
            BUILDKIT_INLINE_CACHE: "1",
        },
        cacheFrom: {
            images: [pulumi.interpolate`${ecrRepository.repositoryUrl}:latest`],
        },
        context: "app/",
        dockerfile: "Dockerfile",
    },
    imageName: pulumi.interpolate`${ecrRepository.repositoryUrl}:latest`,
    registry: {
        password: pulumi.secret(authToken.apply(authToken => authToken.password)),
        server: ecrRepository.repositoryUrl,
    },
});
is a doco example of image caching
we run
docker buildx build ...
directly, then pass the image id in to ECS TaskDefinitions
p
Ok. Let me try it.
For me I was using the awsx.ecr