Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to copy file in docker file which is downloaded in github actions

I can able to see the .pkl which is downloaded using actions/download-artifact@v3 action in work directory along with Dockerfile as shown below,

enter image description here

When I try to COPY file inside Dockefile, I get a file not found error.

enter image description here

How to copy the files inside docker image that are downloaded(through github actions) before building docker image?

Here is doc from github on docker support, but I didn't get exactly how to solve my issue. Any help would be really appreciated!!

Dockerfile:

name: Docker - GitHub workflow

env:
  CONTAINER_NAME: xxx-xxx

on:
  workflow_dispatch:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]


permissions:
  id-token: write
  contents: read

jobs:
  load-artifacts:
    runs-on: ubuntu-latest
    environment: dev
    env:
      output_path: ./xxx/xxx_model.pkl
    
    steps:
      - uses: actions/checkout@v3

      - name: Download PPE model file
        run: |
            az storage blob download --container-name ppe-container --name xxx_model.pkl -f "${{ env.output_path }}"
            
      - name: View output - after
        run: |
          ls -lhR
      
      - name: 'Upload Artifact'
        uses: actions/upload-artifact@v3
        with:
          name: ppe_model
          path: ${{ env.output_path }}

  
  build:
    needs: load-artifacts
    runs-on: ubuntu-latest
    env:
      ACR: xxxx
      
    steps:
      - uses: actions/checkout@v3

      - uses: actions/download-artifact@v3
        id: download
        with:
          name: ppe_model
          # path: ${{ env.model_path }}

      - name: Echo download path
        run: echo ${{steps.download.outputs.download-path}}
      
      - name: View directory files
        run: |
          ls -lhR -a

      - name: Build container image
        uses: docker/build-push-action@v2
        with:
          push: false
          tags: ${{ env.ACR }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.run_number }}
          file: ./Dockerfile
like image 468
Python coder Avatar asked Nov 30 '25 10:11

Python coder


1 Answers

In your workflow file, you're not specifying the context:

      - name: Build container image
        uses: docker/build-push-action@v2
        with:
          push: false
          tags: ${{ env.ACR }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.run_number }}
          file: ./Dockerfile

By default, that means that docker/build-push-action uses a git context. That will re-clone your repository... without your model.

The fix, then, is to specify a path context, like this:

      - name: Build container image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: false
          tags: ${{ env.ACR }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.run_number }}
          file: ./Dockerfile
like image 132
Nick ODell Avatar answered Dec 03 '25 01:12

Nick ODell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!