Krystian
03/18/2025, 10:23 AMMarvin
03/18/2025, 10:23 AM.deploy
method. This process includes building a Docker image with your flow code and optionally pushing it to a Docker registry.
2. Run the Worker: The worker is responsible for executing the flow within a Docker container. You can start a worker for your deployment, which will listen for flow runs and create containers as needed.
For more detailed instructions, you can refer to the Prefect documentation on Docker infrastructure examples.
If you have any specific configurations or further questions, feel free to ask!Krystian
03/18/2025, 10:30 AMMarvin
03/18/2025, 10:30 AM.deploy
method to create a Docker container only when a flow is triggered, you can use several parameters to customize your deployment. Here's a concise guide on how to achieve this:
1. Specify the Docker Image: You can specify the Docker image using the image
argument. If you don't specify an image, you must define where to pull the flow code from at runtime using the from_source
method.
2. Pass Parameters: Use the parameters
argument to pass a dictionary of key-value pairs to your flow.
3. Job Variables: Use the job_variables
parameter to override default infrastructure settings for a deployment. This includes settings like image_pull_policy
and image
.
Here's a basic example of how you might set up the .deploy
method:
python
from prefect import flow
@flow
def my_flow():
# Your flow logic here
pass
my_flow.deploy(
name="my-flow-deployment",
image="my-docker-image:latest",
parameters={"param1": "value1", "param2": "value2"},
job_variables={
"image_pull_policy": "IfNotPresent"
}
)
For more detailed information, you can refer to the Prefect documentation on Docker deployments.