gabe
02/18/2025, 3:26 PMmain.py
file with the flow definition. First I built a docker image using the following Dockerfile:
FROM prefecthq/prefect:3.0.1-python3.12
WORKDIR /app
COPY main.py /app/main.py
CMD ["python", "/app/main.py"]
Then I defined a prefect yaml file:
pull:
- prefect.deployments.steps.set_working_directory:
directory: /app
deployments:
- name: test.prefect.deployment
entrypoint: main.py:dummy_flow
work_pool:
name: worker-pool-staging
job_variables:
image: <my-registry>/test-prefect:latest
work_queue_name:
version:
tags: []
concurrency_limit:
description:
parameters: {}
enforce_parameter_schema: true
schedules: []
However, when I try to run prefect deploy --prefect-file=deployment.yaml
from my local directory, it works. But when I run it from a different directory, it doesn't work and it exits with FileNotFoundError: [Errno 2] No such file or directory: 'main.py'
. So it seems to me like prefect creates the deployment based on my local files. However, I explicitely want it to use only files that are already inside the docker image. Is this possible? How to achieve it?ESmith
02/18/2025, 3:29 PMNate
02/18/2025, 3:47 PMprefect deploy
from anywhere, whether or not your code is there, because it should be good enough for the code to live inside the image?
⢠why are you overriding CMD
in your Dockerfile
?gabe
02/18/2025, 5:10 PMprefect deploy
on that, well, what then? Image has ove version of the code, locar directory another version. Seems like it could be asking for trouble, but correct me if I'm wrong.
As for the CMD
this is just an entrypoint to the docker image. From docker docs: The CMD instruction specifies the default command to run when a container is started from the Docker image. If no command is specified during the container startup (i.e., in the docker run command), this default is used. CMD can be overridden by supplying command-line arguments to docker run.
So it seems to me that it shouldn't interfere with anything prefect-related, but again, if I'm wrong please do correct me.
Thanks,
GabeNate
02/18/2025, 7:34 PMentrypoint
that points to your function. you might want to plus 1 this issue, as it seems like this would help you
So it seems to me that it shouldn't interfere with anything prefect-relatedin containerized deployments we do leverage the entrypoint which is something like
python -m prefect.engine
(i.e. start the prefect engine) so overriding will cause issuesgabe
02/18/2025, 8:22 PMNate
02/18/2025, 9:38 PMMatthew Wiseman
03/07/2025, 11:23 AMNate
03/07/2025, 5:06 PM