Does `flow.deploy` require you to build a new Imag...
# ask-community
m
Does
flow.deploy
require you to build a new Image? I'd want to just pass it an Image we've already built. Seems like the
image
argument requires a
DeploymentImage
object, though?
a
Currently
flow.deploy
builds an image on each run to ensure the flow code is available in the image. You could provide a custom Dockerfile via a
DeploymentImage
object that uses your image as the base image.
m
@alex Oof, that'll add a lot of overhead to our deployment process - our DS images are pretty big.
@alex Could I get some example code for pulling the base image from ECR?
a
Before we go down that path, where do you want to store your flow code? Do you want to bake the flow code into an image, or do you want to pull it from a remote location like a git repo?
m
S3
a
Gotcha, we haven’t built S3 support for
flow.deploy
yet, but once we do, I think using the lower-level
.apply
method might work better. It would look something like this:
Copy code
flow.from_source(
    source="<s3://bucket/folder>",
    entrypoint="flows.py:my_flow
).to_deployment(
    name="my-deployment",
    work_pool_name="my-work-pool",
    job_variables={"image":"IMAGE_NAME"}
).apply()
This will skip building an image and allow you to use your image directly.
🚀 1
m
Ah, interesting, thanks!
@alex Oh, also - for the
job_variables
argument, can I basically pass all the same args I currently pass to my
ECSTask
object that gets passed as the
infrastructure
arg when using
Deployment.build_from_flow
? Thanks!
I'm looking to transition to an ECS Push Work Pool
a
Yeah,
job_variables
here is equivalent to
infra_overrides
in
Deployment.build_from_flow
.
m
Sweet, thanks!
Hrm, would I have to manually push the file first when doing that? So it'd be something like
Copy code
if __name__ == "__main__":
    s3_bucket = S3Bucket.load("my-bucket")
    s3_bucket.download_folder_to_path("flow_folder", "flow_folder")
    flow.from_source(
        source="<s3://my-bucke/flow_folder>", entrypoint="flows.py:my_flow"
    ).to_deployment(
        name="my-deployment",
        work_pool_name="my-work-pool",
        job_variables={"image":"IMAGE_NAME"},
    ).apply()
a
Yeah, your flow code would need to be present in your S3 bucket before calling
flow.from_source
👍 1