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

build stages not being pushed #131

Closed
jilipop opened this issue Aug 10, 2023 · 4 comments · Fixed by #135
Closed

build stages not being pushed #131

jilipop opened this issue Aug 10, 2023 · 4 comments · Fixed by #135

Comments

@jilipop
Copy link

jilipop commented Aug 10, 2023

We've been using v5 in a Github Action successfully for many months and it suddenly stopped pushing the build stages to ECR correctly, always only pushing the last stage with tag "1". I'm not aware of any relevant change on our side. The only thing I noticed is a more recent Github Actions runner version being used. Updating to docker-build-with-cache-action v6 didn't help.

I did a little digging and I think this is what's happening:

Apparently in your docker-build.sh the piping of the output in this code no longer works:

docker build \
    $cache_from \
    --tag "$DUMMY_IMAGE_NAME" \
    --file "${INPUT_CONTEXT}"/"${INPUT_DOCKERFILE}" \
    ${INPUT_BUILD_EXTRA_ARGS} \
    "${extra_args[@]}" \
    "${INPUT_CONTEXT}" | tee "$BUILD_LOG"

The build-output.log remains empty and _get_stages doesn't find any stages, so none get pushed, which in turn messes up our whole deployment.

Anyway, sources on the internet say docker build no longer logs to standard output but rather to the standard error stream, so adding 2>&1 before the pipe operator should fix the problem. It does when I try to write docker build output to both the console and a file locally:

docker build . | tee test.log

--> full output in console, empty test.log

docker build . 2>&1 | tee test.log

--> full output in both console and test.log

@jilipop
Copy link
Author

jilipop commented Aug 10, 2023

Okay, it's not that easy. I've forked this repo and tried the change. build-output.log now does get populated but the output is very different from before and the logic in _get_stages doesn't work on it. Not sure if the different output is because of buildkit now being used.

@jilipop
Copy link
Author

jilipop commented Aug 10, 2023

Yeah, it was because of buildkit. This did the trick for now:

- name: Build and push the Docker image
      env:
        DOCKER_BUILDKIT: 0
      uses: whoan/[email protected]
      [...]

Might be good to add this to your examples.

There's a warning about this environment variable being deprecated, so this solution might not be permanent.

@jilipop jilipop closed this as completed Aug 10, 2023
@MC-Dave
Copy link

MC-Dave commented Sep 21, 2023

This issue still exists in v6.

The *-stages layers are exported and pushed to ECR (I used ECR in my use case) successfully. However, each run results in a complete rebuild of all images, after pulling stage layers.

RESOLUTION: adding the following line under each step which uses this action (thanks @jilipop) resolved the issue for me in v6

      env:
        DOCKER_BUILDKIT: 0

@whoan
Copy link
Owner

whoan commented Oct 24, 2023

Now this works again even with BuildKit enabled in v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants