Skip to content

Failed to build an image if dockerfile contains "future" output values #96

@xunleii

Description

@xunleii

What happened?

To give some context, I'm trying to “modify” images on the fly to inject files directly into a previously created image. To do this, I need to reference a previous image into the dockerfile field (see example).

Unfortunately, pulumi doesn't seem to appreciate this behavior and tries to search for a Dockerfile, as if the dockerfile were empty :

Update preview (dev) :
     Type Name Plan Info
 + pulumi:pulumi:Stack pulumi-docker-build-issues-dev create
 + ├─ docker-build:index:Image a create 1 warning
     └─ docker-build:index:Image b 1 error

Diagnostics :
  docker-build:index:Image (a):
    warning : Skipping preview build because some inputs are unknown. docker-build:index:Image (b):
    error: docker-build:index:Image resource 'b': property dockerfile.location value {<nil>} has a problem: open <redacted>/Dockerfile: no such file or directory  

Example

import * as pulumi from "@pulumi/pulumi";
import * as docker from "@pulumi/docker-build";

const a = new docker.Image("a", { 
    push: true,
    context: { location: "." },
    dockerfile: {inline: "FROM busybox\n"},
    tags: ["localhost/pulumi/a:latest"],
});
const b = new docker.Image("b", {
    push: true,
    context: { location: "." },
    dockerfile: {inline: pulumi.interpolate`FROM ${a.ref}\n`},
    tags: ["localhost/pulumi/b:latest"],
});

export const images = {
    a: a.ref,
    b: b.ref,
};

Output of pulumi about

CLI
Version      3.119.0
Go Version   go1.22.3
Go Compiler  gc                                                                                                                                                                                                                                                                                                                                                                                                                     Plugins
KIND      NAME          VERSION
resource  docker-build  0.0.2
language  nodejs        unknown                                                                                                                                                                                                                                                                                                                                                                                                     Host
OS       ubuntu
Version  22.04
Arch     x86_64                                                                                                                                                                                                                                                                                                                                                                                                                     This project is written in nodejs: executable='${HOME}/.asdf/shims/node' version='v20.10.0'                                                                                                                                                                                                                                                                                                                                 Backend
Name           <redacted>
URL            file://~
User           <redacted>
Organizations
Token type     personal                                                                                                                                                                                                                                                                                                                                                                                                             Dependencies:
NAME                  VERSION
@pulumi/docker-build  0.0.2
@pulumi/pulumi        3.119.0
@types/node           18.19.34
typescript            5.4.5

Pulumi locates its logs in /tmp by default
warning: Failed to get information about the current stack: No current snapshot

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-upstreamAwaiting upstream dependencyimpact/usabilitySomething that impacts users' ability to use the product easily and intuitivelykind/bugSome behavior is incorrect or out of spec

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions