Serve and deploy apps

An LLM-optimized bundle of this entire section is available at section.md. This single file contains all pages in this section, optimized for AI coding agent context.

Flyte provides two main ways to deploy apps: serve (for development) and deploy (for production). This section covers both methods and their differences.

Serve vs Deploy

flyte serve

Serving is designed for development and iteration:

  • Dynamic parameter modification: You can override app parameters when serving
  • Quick iteration: Faster feedback loop for development
  • Interactive: Better suited for testing and experimentation

flyte deploy

Deployment is designed for production use:

  • Immutable: Apps are deployed with fixed configurations
  • Production-ready: Optimized for stability and reproducibility

Using Python SDK

ServeDeploy
serve_and_deploy_examples.py
app_env = flyte.app.AppEnvironment(
    name="my-app",
    image=flyte.app.Image.from_debian_base().with_pip_packages("streamlit==1.41.1"),
    args=["streamlit", "hello", "--server.port", "8080"],
    port=8080,
    resources=flyte.Resources(cpu="1", memory="1Gi"),
)

if __name__ == "__main__":
    flyte.init_from_config()
    app = flyte.serve(app_env)
    print(f"Served at: {app.url}")
serve_and_deploy_examples.py
app_env = flyte.app.AppEnvironment(
    name="my-app",
    image=flyte.app.Image.from_debian_base().with_pip_packages("streamlit==1.41.1"),
    args=["streamlit", "hello", "--server.port", "8080"],
    port=8080,
    resources=flyte.Resources(cpu="1", memory="1Gi"),
)

if __name__ == "__main__":
    flyte.init_from_config()
    deployments = flyte.deploy(app_env)
    # Access deployed app URL from the deployment
    for deployed_env in deployments[0].envs.values():
        print(f"Deployed: {deployed_env.deployed_app.url}")

Using the CLI

ServeDeploy
flyte serve path/to/app.py app_env
flyte deploy path/to/app.py app_env

Next steps