I am using the projects flow and building and dock...
# ask-community
g
I am using the projects flow and building and docker image with the code baked into it. How do I tell the deploy to use the correct path as it keep trying to use the path of the code on my local machine and no the path in the container
a
Hey @Gregory Hunt! Can you share your
prefect.yaml
file and the
prefect deploy
command that you’re running?
g
Copy code
definitions:
    actions:
        docker_build: &docker_build
            - prefect_docker.projects.steps.build_docker_image: &docker_build_config
                requires: prefect-docker>=0.2.0
                image_name: prefect-default
                tag: dev
                dockerfile: Dockerfile.default
                push: false
deployments:
- name: my-first-deployment
  version: null
  tags: ["test"]
  description: "Basic Local Deployment"
  schedule: {}
  entrypoint: ./src/flows/basic-flow.py:pipeline
  parameters: {}
  work_pool:
    name: localwork
- name: my-first-docker-deployment
  version: null
  tags: ["docker"]
  description: "Basic Docker Deployment"
  schedule: {}
  entrypoint: ./src/flows/basic-flow.py:pipeline
  parameters: 
    path: /home/prefect
  work_pool:
    name: docker-work
    job_variables:
      image: 'prefect-default:dev'
  build: *docker_build
prefect deployment run 'Previously Unreliable Pipeline/my-first-docker-deployment'
FileNotFoundError: [Errno 2] No such file or directory: '/Users/ghunt/code/particlehealth/proton/prefect'
Copy code
FROM prefecthq/prefect:2.10.13-python3.9
LABEL description="Prefect CloudRun default"

RUN mkdir /home/prefect
COPY src /home/prefect/src
is the dockerfile
a
Thanks for sharing! What does your
prefect.yaml
look like? I think your
pull
step may need to be updated.
g
Copy code
# File for configuring project / deployment build, push and pull steps

# Generic metadata about this project
name: prefect
prefect-version: 2.10.13

# build section allows you to manage and build docker images
build: null

# push section allows you to manage if and how this project is uploaded to remote locations
push: null

# pull section allows you to provide instructions for cloning this project in remote locations
pull: null
a
Gotcha, I think you’ll want to add a pull step to your
my-first-docker-deployment
that looks like this:
Copy code
pull:
    - prefect.projects.step.set_working_directory:
          directory: /home/prefect
That will ensure that your flow run gets kicked off from the correct directory.
g
sweet that fixed
🎉 1
@alex one more question about that deployment file
can i reference the full image:tag path from the build step in the deployment as a variable
See where I am passing in the job_variable:image as a string, can that be pulled from the build step
a
Yep! You can update your
work_pool
section to look like this:
Copy code
work_pool:
    name: docker-work
    job_variables:
      image: '{{ image_name }}'