RafikFarhad / push-to-gcr-github-action

An action that build docker image and push to Google Cloud Registry and Google Artifact Registry.
MIT License
68 stars 37 forks source link

Question about context path #45

Open Kakcalu13 opened 10 months ago

Kakcalu13 commented 10 months ago

The snippet below:

      - name: Push to GCR GitHub Action
        uses: RafikFarhad/push-to-gcr-github-action@v4.1
        with:
          gcloud_service_key: ${{ secrets.GCR_SERVICE }}
          project_id: feagi-poc
          image_name: test
          image_tag: latest
          dockerfile: ./tmp/playground/Dockerfile
          context: /

The dockerfile I have is in /tmp/playground

how come I couldn't use like this:

          dockerfile: .Dockerfile
          context: ./tmp/playground

or

          dockerfile: ./tmp/playground/Dockerfile
          context: ./tmp/playground

None of them worked. I'm unable to access to see where is the default path it is in. How do I direct context to get the /tmp/playground?

RafikFarhad commented 10 months ago

This should work except the . in front of Dockerfile

dockerfile: Dockerfile
context: ./tmp/playground

Build process will set the context first and will look for the Dockerfile

Kakcalu13 commented 10 months ago

Thanks @RafikFarhad!

Testing it now

Kakcalu13 commented 10 months ago

Unfortunately, that did not work. Sounds like it couldn't run the dockerfile anywhere, it has to be inside the current directory. See here:

I added one job before push to gcr.

image

Then the next job (which is the same one as above plus your change/suggestion: image

See the snippet of yml:

      - name: debugging playground
        working-directory: /tmp/playground
        run: |
          pwd
          echo "ls playground"
          ls
      - name: Push to GCR GitHub Action
        uses: RafikFarhad/push-to-gcr-github-action@v4.1
        with:
          gcloud_service_key: ${{ secrets.GCR_SERVICE }}
          project_id: feagi-poc
          image_name: feagi-dev/playground
          image_tag: ${{ github.run_number }}, latest
          dockerfile: Dockerfile
          context: ./tmp/playground

Honestly, I don't see anything wrong with your suggestion. If you have more ideas, I'd love to hear them since I've hit the block now :(

tntchn commented 10 months ago

See the snippet of yml:

      - name: debugging playground
        working-directory: /tmp/playground
        run: |
          pwd
          echo "ls playground"
          ls
      - name: Push to GCR GitHub Action
        uses: RafikFarhad/push-to-gcr-github-action@v4.1
        with:
          gcloud_service_key: ${{ secrets.GCR_SERVICE }}
          project_id: feagi-poc
          image_name: feagi-dev/playground
          image_tag: ${{ github.run_number }}, latest
          dockerfile: Dockerfile
          context: ./tmp/playground

thought your working directory in previous step is actually /tmp/playground, you should use

             context: /tmp/playground

instead of ./tmp/playground (which is /home/runner/work/{repo_owner}/{repo}/tmp/playground )

I guess the content of /tmp/playground were created by a previous step which was not included in your repo, so docker could not found the context with the wrong PATH

Kakcalu13 commented 7 months ago

oh oops, sorry for the delay! I came back to this repo for an arg to build usnig arm64 and I saw a new reply. I will try it out! Thank you for ur time!