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

How to use artifacts in build-push-action? #592

Closed
KEGustafsson opened this issue Apr 11, 2022 · 5 comments
Closed

How to use artifacts in build-push-action? #592

KEGustafsson opened this issue Apr 11, 2022 · 5 comments

Comments

@KEGustafsson
Copy link

KEGustafsson commented Apr 11, 2022

I tried to figuring out how to use artifacts in build-push-action, but didn't find the info?

I can upload and download artifacts in GH action. I can see that artifacts are in correct folder, but after starting docker/build-push-action@v2 action and doing ADD "folder" in docker build Dockerfile, folder is not containing just downloaded artifacts.

It seems that docker buildx build is loading git source, but not the one I have checked out.
How this should be done?

@crazy-max
Copy link
Member

@KEGustafsson If you could post a repro (workflow + simple dockerfile + logs) that would help to understand the issue. Thanks.

@KEGustafsson
Copy link
Author

KEGustafsson commented Apr 11, 2022

@crazy-max Here is one example what I'm trying to do
https://gist.github.com/KEGustafsson/d57419e6f82f9fda98f37f6d7d0e04df

So, script download artifact to temp and then run build-push. Dockerfile ADD import folder to docker, but content is missing. Just downloaded artifact is not there.

Replacing GH action build-push to run cmd (below) works fine and temp file content is available to docker build.

     - name: Run Buildx docker and push
        run: |
          docker buildx build \
            --platform linux/amd64,linux/arm64,linux/arm/v7 \
            -t "latest" \
            -f ./docker/Dockerfile \
            --push .

@crazy-max
Copy link
Member

Looks like you're using the Git context. As explained in the README:

Be careful because any file mutation in the steps that precede the build step
will be ignored, including processing of the .dockerignore file
since
the context is based on the Git reference. However, you can use the
Path context using the context input alongside
the actions/checkout action to remove
this restriction.

So use the Path context instead:

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./docker/Dockerfile
          platforms: linux/amd64,linux/arm/v7,linux/arm64
          push: true
          images: <user>/<repo>
          tags: latest

@crazy-max
Copy link
Member

crazy-max commented Apr 11, 2022

Also this input doesn't exist:

          images: <user>/<repo>

@KEGustafsson
Copy link
Author

Thanks! Working perfectly!

Also this input doesn't exist:

          images: <user>/<repo>

Original was removed and replaced with this...

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

No branches or pull requests

2 participants