Replies: 1 comment 6 replies
-
hi @Lukem76! I notice you say
If this is the case, all you need to do is update your if __name__ == "__main__":
buy.deploy(
name="my-deployment",
work_pool_name="my-work-pool",
job_variables={"image": "your-registry/your-image:your-tag"},
push=False
) to tell prefect use your if you do want to build your own image, keep readingi am not yet sure about the FROM prefecthq/prefect:3-latest
WORKDIR /opt/prefect
COPY examples/run_flows_on_docker/buy.py examples/run_flows_on_docker/buy.py There are numerous valid ways to write your dockerfile, but I did it like this because I was running my script from the root of the repo and wanted to bake my flow into the image to reproduce your situation » python examples/run_flows_on_docker/buy.py |
Beta Was this translation helpful? Give feedback.
-
I have a project with a simple python file that is containerized with a Dockerfile.
The dockerfile is:
prefect-test.py
is a simple file that print a message. If I build the image locally with Docker Desktop and run it, it works. I already pushed it on docker hub in a public repo.Now I want to start a Prefect server versione 3 (not 2, it's important). I created this Dokerfile:
I build the image and ran it with:
docker build -t prefect-server . docker run -d -p 4200:4200 --name prefect-server prefect-server
Then I access the GIU at http://localhost:4200
Everything works.
Now I want to create a work pool, start an agent and do a deploy. The target is to create a deploy file that run the Dockerimage that run the prefect-test.py file.
I create the work pool with:
I started a worker:
Now I have to define the deployment. I created a file named deploy_buy.py in a different folder than the root where I have the Dockerfile and prefect-test.py file:
I copied it from official doc here: https://docs.prefect.io/v3/deploy/infrastructure-examples/docker
If I run the task, I see the message "Buying securities" in logs and at the end I see:
Finished in state Completed()
Process for flow run 'xxx' exited cleanly.
But the file prefect-test.py wasn't invoked, because I don't see any other log.
I used a different folder for deploy file because, if I don't do that, when I run deploy, it gives me an error saying that a Dockerfile is already in that folder. Executing in a different folder, it creates automatically a Dockerfile with this:
This is not clear, because that file doesn't contain anything about how to run my
prefect-test.py
file. For this reason I created another deploy file in the root of my project with this:I used dockerfile="Dockerfile" because I want Prefect to use my Dockerfile. If I remove that line and try to make a deploy, as I wrote above, Prefect tells me that I already have a Dockerfile in that folder. With that line, I get no error.
I don't want prefect create another build and push it, but I want it uses the image I already have on dockerhub. For this reason I put also:
push=False
If I deploy it and run the task, I get error:
This is strange because that import is the same of the one in the example on Prefect v3 docs.
Any ideas?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions