Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build doesn't always run during preview #472

Closed
joeduffy opened this issue Dec 15, 2019 · 1 comment
Closed

Docker build doesn't always run during preview #472

joeduffy opened this issue Dec 15, 2019 · 1 comment
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@joeduffy
Copy link
Member

It looks like we only execute the Docker build during previews when the target repository is actually available. If it isn't, the Docker build is skipped. This means that you might not find a Docker build error during previews until after the repository actually exists.

For instance, consider a simple program:

import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

const repo = new awsx.ecr.Repository("repo");
export const image = repo.buildAndPushImage("./app");

with an intentionally broken Dockerfile:

FROM nginx
COPY Xindex.html /usr/share/nginx/html

Now observe the following sequence of updates:

$ pulumi up
Previewing update (dev):

     Type                           Name            Plan
 +   pulumi:pulumi:Stack            docker-pac-dev  create
 +   └─ awsx:ecr:Repository         repo            create
 +      ├─ aws:ecr:Repository       repo            create
 +      └─ aws:ecr:LifecyclePolicy  repo            create

Resources:
    + 4 to create

Do you want to perform this update? yes
Updating (dev):

     Type                           Name            Status                  Info
 +   pulumi:pulumi:Stack            docker-pac-dev  created
 +   └─ awsx:ecr:Repository         repo            **creating failed**     2 errors
 +      ├─ aws:ecr:Repository       repo            created
 +      └─ aws:ecr:LifecyclePolicy  repo            created

Diagnostics:
  awsx:ecr:Repository (repo):
    error: COPY failed: stat /var/lib/docker/tmp/docker-builder041295080/Xindex.html: no such file or directory

    error: Error: ' docker build ./app -t 12fda807-container' failed with exit code 1
    Sending build context to Docker daemon  3.072kB
    Step 1/2 : FROM nginx
     ---> 62c261073ecf
    Step 2/2 : COPY Xindex.html /usr/share/nginx/html

        at /Users/joeduffy/temp/docker-pac/node_modules/@pulumi/docker.ts:546:15
        at Generator.next (<anonymous>)
        at fulfilled (/Users/joeduffy/temp/docker-pac/node_modules/@pulumi/docker/docker.js:18:58)
        at process._tickCallback (internal/process/next_tick.js:68:7)

Resources:
    + 4 created

Duration: 7s

Permalink: https://app.pulumi.com/joeduffy/docker-pac/dev/updates/3

$ pulumi up
Previewing update (dev):

     Type                    Name            Plan     Info
     pulumi:pulumi:Stack     docker-pac-dev
     └─ awsx:ecr:Repository  repo                     2 errors

Diagnostics:
  awsx:ecr:Repository (repo):
    error: COPY failed: stat /var/lib/docker/tmp/docker-builder424369959/Xindex.html: no such file or directory

    error: Error: ' docker build ./app -t 12fda807-container' failed with exit code 1
    Sending build context to Docker daemon  3.072kB
    Step 1/2 : FROM nginx
     ---> 62c261073ecf
    Step 2/2 : COPY Xindex.html /usr/share/nginx/html

        at /Users/joeduffy/temp/docker-pac/node_modules/@pulumi/docker.ts:546:15
        at Generator.next (<anonymous>)
        at fulfilled (/Users/joeduffy/temp/docker-pac/node_modules/@pulumi/docker/docker.js:18:58)

Notice:

  • The first preview succeeded fine (and apparently didn't run docker build).
  • The actual update then failed, when the docker build ran.
  • The second preview failed (because it did run docker build -- unlike the first preview).

I assume the build is somehow conditional on an output variable being available during preview. I would have expected, and appreciated, both previews failing -- or at least being consistent.

@mnlumi
Copy link
Contributor

mnlumi commented Jul 28, 2023

Using a more recent program with awsx: 1.0.2, preview does run docker build each time and the invalid Dockerfile is caught on preview. The failure occurs consistenly.

import * as awsx from "@pulumi/awsx";

const repository = new awsx.ecr.Repository("repository", { forceDelete: true });

export const image = new awsx.ecr.Image("image", {
  repositoryUrl: repository.repository.repositoryUrl,
  path: "./app",
}).imageUri;

I will make a note that as the version of the docker provider within awsx is updated to consume v4, this scenario should be validated again during testing.

@mnlumi mnlumi closed this as completed Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

2 participants