Hello, I'm having trouble building a docker contai...
# prefect-cloud
b
Hello, I'm having trouble building a docker container with dependencies built in. I'm getting the following error when the deployment is run:
Copy code
FileNotFoundError: [Errno 2] No such file or directory: '/opt/prefect/flows'
I'm running my own docker build, but managing the deploy through `prefect.yaml`:
Copy code
name: orchestration
prefect-version: 2.16.6

pull:
- prefect.deployments.steps.set_working_directory:
    directory: /opt/prefect/flows

deployments:
- name: "test deployment"
  tags: []
  schedule: null
  entrypoint: 'flows/control_flows.py:test_flow'
  parameters: {}
  work_pool:
    name: 'kubernetes-work-pool'
    work_queue_name: 'default'
    job_variables:
      image: '<my_ecr_repo>:my_build_tag'
Docker build steps:
Copy code
docker build --platform=linux/arm64 --no-cache -f ./Dockerfile ..
tag:
Copy code
docker tag <hash_from_build_above> <my_ecr_repo>:my_build_tag
And, Dockerfile:
Copy code
FROM prefecthq/prefect:2-python3.9

# Create the user
COPY kubernetes/requirements.txt /requirements.txt
# use absolute path when installing requirements
RUN pip3 install -r /requirements.txt --trusted-host <http://pypi.python.org|pypi.python.org> --no-cache-dir

COPY orchestration/flows /opt/prefect/flows
My flow code lives at
orchestration/flows/control_flows.py
and is:
Copy code
from prefect import flow
@flow(name="test_flow", log_prints=True)
def test_flow():
    print("test_flow")
n
hi @Bryce Derriso - i would pop into that container to sanity check that things are where you expect with
docker run -it
if you haven’t already
b
yep, things look right to me:
Copy code
root@d8458ee4800f:/opt/prefect/flows# pwd
Copy code
/opt/prefect/flows
Copy code
root@d8458ee4800f:/opt/prefect/flows# ls
Copy code
__pycache__  control_flows.py
Copy code
root@d8458ee4800f:/opt/prefect/flows# cat control_flows.py
Copy code
from prefect import flow


@flow(name="test_flow", log_prints=True)
def test_flow():
    print("test_flow")
Hello, I'm still getting an issue
Copy code
FileNotFoundError: [Errno 2] No such file or directory: '/opt/prefect/flows'
When trying to run a Flow in a custom docker container from a Kubernetes worker. Does anyone have any ideas for fixing this?
l
We are getting the same issue as well when running with a "Docker" work-pool. The worker connected is always pulling the latest Prefect Dockerimage instead of our own images, which are stored in docker_container blocks.
This notice does not seem to be true for our deployments:
n
@Lennert Van de Velde workers are incompatible with infrastructure blocks. you'd use a docker work pool migration guide
hey @Bryce Derriso - I still suspect there's some pathing issue inside the container, could be wrong any chance you could add a
prefect.deployments.steps.run_shell_script
step after your set working directory step with an
ls -a
or something?
b
Yeah, I can do that. Can you point me to any documentation about the
prefect.deployments.steps.*
available, and what they do? I can guess what
run_shell_script
does, but haven't seen what all my options are here.
im not sure we have a comprehensive list in the docs, but in case its helpful
prefect.deployment.steps.*
are all just fully qualified names of functions in our repo
b
but in case its helpful prefect.deployment.steps.* are all just fully qualified names of functions in our repo
Ah! That's very helpful, got it!