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,
When I try to COPY
file inside Dockefile, I get a file not found error.
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
CodePudding user response:
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
choose 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