<@ULVA73B9P> I'm currently deploying a flow as fol...
# ask-marvin
n
@Marvin I'm currently deploying a flow as follows:
prefect deployment build main.py:main -n main -ib docker-container/my-docker-container -a
How would I deploy this flow with the new approach?
m
Here's how you can deploy your flow in Prefect 2.x using blocks: 1. Create Deployment without CLI Argument: Prefect 2.x allows a more flexible way by using deployment scripts. Prefect introduces the
Deployment
class to manage deployments programmatically:
Copy code
python
   from prefect.deployments import Deployment
   from prefect.infrastructure.docker import DockerContainer
   from main import main_flow  # assuming your flow is defined as main_flow in main.py

   docker_block = DockerContainer.load("my-docker-container")

   deployment = Deployment.build_from_flow(
       flow=main_flow,
       name="main",
       infrastructure=docker_block
   )

   deployment.apply()
2. Using the CLI: Alternatively, you can still use CLI commands but with updated syntax for blocks. - First, ensure your Docker block is registered in the Prefect UI or through scripts. - Then, build and apply the deployment:
Copy code
sh
     prefect deployment build main.py:main_flow -n main -ib docker-container/my-docker-container -a
Additional Documentation and Resources: - Migration Guide - Deployment Image - Concepts: Deployments (Block-Based) These resources thoroughly explain the new deployment methodology in Prefect 2.x. Isn't it wonderful how every new iteration adds more complications... I mean facilities?
n
The second approach is going to be deprecated right?