preswald deploy

The preswald deploy command deploys your application to a desired environment, such as Structured Cloud, Google Cloud Platform, or a local container. It streamlines the deployment process, handling configuration and execution seamlessly.

Note: preswald deploy creates a .env.structured in the current directory for Structured Cloud deployments that is useful for preswald stop and preswald deployments.

Options

  • --target: Specifies the deployment target. Options include:
    • structured: Deploys to Structured Cloud. Requires Structured API Key.
    • gcp: Deploys to Google Cloud Platform. Requires GCloud CLI installed.
    • local (default): Builds and runs a container locally without deploying to the cloud.
  • port (int):
    The port on which to run the Preswald server. Default is 8501
  • log-level (str):
    The log level for the Preswald server. Options are DEBUG, INFO, WARNING, ERROR, CRITICAL. Default is INFO
  • github (str):
    Github username (what you used to create your structured account with).
  • api-key (str):
    Structured API Key. See app.preswald.com for account and org details.

Requirements for Cloud Deployment

  • Structured Cloud Deployment:
    Get an API key from Settings at https://app.preswald.com. The CLI will provide guidance on setup.
  • Google Cloud Deployment:
    Install the GCloud CLI. If not, the CLI will provide guidance on setup.

Example Deployment Commands

1. Structured Cloud Deployment

To deploy your app to Structured Cloud:

preswald deploy --target structured --github <github-username> --api-key <structured-api-key> hello.py

This command packages your app into a container and deploys it to Structured Cloud, providing a shareable live preview link.


2. Google Cloud Run Deployment

To deploy your app to Google Cloud Run:

preswald deploy --target gcp

This command packages your app into a container and deploys it to Google Cloud Run, providing a shareable live preview link.


3. AWS Deployment (Coming soon!)

To deploy your app to AWS:

preswald deploy --target aws

Install and configure AWS CLI before running this command.


4. Local Deployment (Dry Run)

To build and test your app locally without deploying it to the cloud:

preswald deploy --target local

This creates a container locally for testing purposes.


5. Default Deployment

If no --target is specified, the deployment defaults to local execution:

preswald deploy

This builds and runs your app in a local container.


What Preswald Handles

  • Cloud deployment: Automates the process of containerizing your app, configuring the environment, and deploying it to the target platform.
  • Local testing: Builds a container locally to let you verify your app before cloud deployment.
  • Live preview: Provides a shareable URL (for cloud deployments) so others can interact with your app.

With preswald deploy, you can transition from local testing to cloud deployment in a few simple steps, making your app accessible to a broader audience.