kitabisa / docker-slim-action

GitHub Action to minify container image by up to 30x (and for compiled languages even more) making it secure too!
MIT License
22 stars 5 forks source link

no docker credentials provider found with docker-login action against GAR #7

Closed gabsemeraro closed 7 months ago

gabsemeraro commented 7 months ago

Hi,

I'm using the docker-slim-action as following:

      - name: Login to Artifact Registry DEV
        uses: docker/login-action@v3
        with:
          registry: europe-west1-docker.pkg.dev
          username: _json_key
          password: '${{ _secrets.myvalidsecret }}'
          logout: false

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Build Container Image DEV
        id: docker-push-tagged-dev
        uses: docker/build-push-action@v4
        with:
          context: .
          push: false
          file: ${{ env.REPONAME }}/dockerfile
          tags: |
            ${{ env.REPONAME }}:latest
          build-args: |
            ACR=${{ env.GAR }}/shared

      - name: Slim container image
        uses: kitabisa/docker-slim-action@v1
        env:
          DSLIM_HTTP_PROBE: false
        with:
          target: ${{ env.REPONAME }}:latest
          tag: |
            ${{ env.GAR }}/services/${{ env.REPONAME }}:slim

      - name: Push Container Image
        run: |
         docker image push "${{ github.repository }}" --all-tags

But I'm getting the following error:

 Using slim version 1.40.11
slim on target: ml-service:latest
/tmp/slim-DOw182/dist_linux/slim b --target ml-service:latest --continue-after 1
cmd=build state=started
cmd=build info=params tags='' image-build-engine='internal' target.type='image' target.image='ml-service:latest' continue.mode='timeout' rt.as.user='true' keep.perms='true' 
cmd=build info=target.image status='image.not.found' image='ml-service:latest' message='trying to pull target image' 
time="[20](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:21)24-03-14T17:29:34Z" level=warning msg="image.inspector.Pull: failed to acquire local docker credential helpers for https://index.docker.io err=no docker credentials provider found"
time="2024-03-14T17:29:34Z" level=warning msg="image.inspector.Pull: failed to get registry credential for registry=https://index.docker.io with err=no docker credentials provider found"
cmd=build info=report file='slim.report.json' 
cmd=build info=fail.on version='linux/amd64|Transformer|1.40.11|1b271555882eacdfb4e6598d6d0552e9b9b1449b|2024-02-02_01:36:22PM' 
cmd=build info=exit code='-1' version='linux/amd64|Transformer|1.40.11|1b271555882eacdfb4e6598d6d0552e9b9b1449b|2024-02-02_01:36:22PM' location='/tmp/slim-DOw182/dist_linux' 
app='slim' message='GitHub Discussions' info='https://github.com/slimtoolkit/slim/discussions'
app='slim' message='Join the CNCF Slack channel to ask questions or to share your feedback' info='https://cloud-native.slack.com/archives/C059QP1RH1S'
app='slim' message='Join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
app='slim' message='Join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'
time="2024-03-14T17:29:35Z" level=error msg=terminating error="API error (404): pull access denied for ml-service, repository does not exist or may require 'docker login': denied: requested access to the resource is denied" stack="goroutine 1 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x5e\ngithub.com/slimtoolkit/slim/pkg/app.(*ExecutionContext).FailOn(0xc000508c40, ***0x231e3e0, 0xc0004aa120***)\n\tgithub.com/slimtoolkit/slim/pkg/app/execontext.go:58 +0x58\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.inspectFatImage(0xc000508c40, ***0x7ffe2c81c[21](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:22)8, 0x11***, 0x1, 0x0?, 0x0, ***0x0, 0x0***, ***0x0, 0x0***, ...)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/image.go:58 +0x35a\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.OnCommand(_, _, ***_, _***, _, ***_, _***, ***_, _***, ***0x0, ...***, ...)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/handler.go:620 +0x292d\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.glob..func1(0xc000404400)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/cli.go:760 +0x5d51\ngithub.com/urfave/cli/v2.(*Command).Run(0x3396180, 0xc0000d3b80)\n\tgithub.com/urfave/cli/v2@v2.3.0/command.go:163 +0x583\ngithub.com/urfave/cli/v2.(*App).RunContext(0xc000480820, ***0x233bb88?, 0x340d500***, ***0xc0000501e0, 0x6, 0x6***)\n\tgithub.com/urfave/cli/v2@v2.3.0/app.go:313 +0xaa5\ngithub.com/urfave/cli/v2.(*App).Run(...)\n\tgithub.com/urfave/cli/v2@v2.3.0/app.go:[22](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:23)4\ngithub.com/slimtoolkit/slim/pkg/app/master.Run()\n\tgithub.com/slimtoolkit/slim/pkg/app/master/app.go:15 +0x45\nmain.main()\n\tgithub.com/slimtoolkit/slim/cmd/slim/main.go:15 +0x187\n"
/home/runner/work/_actions/kitabisa/docker-slim-action/v1/node_modules/@actions/exec/lib/toolrunner.js:592
                error = new Error(`The process '$***this.toolPath***' failed with exit code $***this.processExitCode***`);
                        ^

Error: The process '/tmp/slim-DOw182/dist_linux/slim' failed with exit code [25](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:26)5
    at ExecState._setResult (/home/runner/work/_actions/kitabisa/docker-slim-action/v1/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/kitabisa/docker-slim-action/v1/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/kitabisa/docker-slim-action/v1/node_modules/@actions/exec/lib/toolrunner.js:469:[27](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:28))
    at ChildProcess.emit (node:events:513:[28](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:29))
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:[30](https://github.com/OversonicRobotics/sample-service/actions/runs/8284984703/job/22671716065#step:23:31)4:5)
Dilaz commented 7 months ago

I got the same issue today. Turns out that at least in docker/build-push-action@v4, you need to add load: true so the image is actually available "locally"

gabsemeraro commented 7 months ago

It works! Thanks @Dilaz