https://pulumi.com logo
#general
Title
# general
p

proud-keyboard-93811

03/27/2024, 7:57 AM
Hi Team, Is there a way to cache Pulumi stack resource creation instead of rebuilding the whole stack again.
c

cuddly-computer-18851

03/27/2024, 9:39 AM
Stack resources are stored in the pulumi state files. Can you clarify what sequence of commands you're attempting to optimise?
p

proud-keyboard-93811

03/27/2024, 9:39 AM
The pulumi up command when provisioning resources.
c

cuddly-computer-18851

03/27/2024, 9:40 AM
pulumi up
won't rebuild resources, unless you're using a weird Provider
p

proud-keyboard-93811

03/27/2024, 9:40 AM
I don't want it to build everything from scratch including the resource.
Ok.
Maybe my configuration is bad. Let me check.
c

cuddly-computer-18851

03/27/2024, 9:42 AM
What does
pulumi preview
tell you it intends on doing?
p

proud-keyboard-93811

03/27/2024, 9:43 AM
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

cuddly-computer-18851

03/27/2024, 9:44 AM
I see. Personally I don't use the docker provider to build my images, I do that in a distinct CICD step.
p

proud-keyboard-93811

03/27/2024, 9:45 AM
PS: I am using Jenkins CI
Would you mind to share how you go about it?
c

cuddly-computer-18851

03/27/2024, 9:46 AM
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

proud-keyboard-93811

03/27/2024, 9:47 AM
Ok. Let me try it.
For me I was using the awsx.ecr