How to build deployments with flow code and dependencies being baked into a Docker image?

After we introduced the new way of deploying flows in the Prefect 2.0 General Availability release, many users requested a setup where they don’t need to have a separation between storage and infrastructure blocks and can bake all flow code and module dependencies into a single Docker image.

With this PR, we introduced:

  • --apply flag on build CLI and a corresponding apply kwarg on Deployment.build_from_flow allowing you to build and apply the deployment in one step

  • automatic detection of docker infrastructure + non-remote storage; in this situation, the assumption is that the flow code is baked into the image --a default deployment path for flows is considered to be /opt/prefect/flows but you can fully adjust it using the --path /opt/prefect/another_dir

Here is an example repository showing how to use that deployment pattern:

This release blog post explains it more:

2 Likes