Skip to main content

Deploy to Restack with Cloud SDK

Project description

Restack Cloud sdk

Restack Cloud SDK allows you to manage and deploy stacks and applications to the Restack platform.

Installation

First, install the necessary dependencies:

pip install restack-sdk-cloud

Configuration

Create a .env file in the root of your project and add your Restack Cloud token: To get your cloud token navigate to the restack console and generate a new one under your workspace settings.

RESTACK_CLOUD_TOKEN=your_restack_cloud_token

In case you don't want the SDK to ask for your confirmation before applying changes set on your .env. This is ideally set on your cicd pipeline so there is no blocking prompt and deployment doesn't asks for user confirmation.

RESTACK_CICD=true

Usage

Below is an example of how to use the Restack Cloud SDK to create and deploy stacks and applications.

Example

Create a file named restack_up.py and add the following content:

import os
from restack_sdk_cloud import RestackCloud

async def main():
    # Initialize the RestackCloud client with the Cloud token from environment variables
    restack_cloud_client = RestackCloud(os.getenv('RESTACK_CLOUD_TOKEN'))

    # Define the frontend application configuration
    frontend_app = {
        'name': 'frontend-python',
        'dockerFilePath': 'frontend/Dockerfile',
        'dockerBuildContext': 'frontend',
        'environmentVariables': [
            {
                'name': 'NEXT_PUBLIC_API_HOSTNAME',
                'linkTo': backend_app['name'],
            },
        ],
    }

    # Configure the stack with the applications
    await restack_cloud_client.stack({
        'name': 'development environment python',
        'previewEnabled': False,
        'applications': [frontend_app],
    })

    # Deploy the stack
    await restack_cloud_client.up()

# Run the main function
if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

API

- `token`: Your Restack SDK token. You can generate a token in the Restack console under your workspace settings.

## Notes

Stack names are used as unique identifiers, so when creating multiple stacks on restack_up config file please make sure names are unique. Application name uniqueness is only bound to the scope inside the stack it belongs to. Meaning you can have two apps with same name as long as they are not part of the same stack.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

restack_sdk_cloud-1.0.13-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file restack_sdk_cloud-1.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for restack_sdk_cloud-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 70e3f4763bc66a17e908c76d3b789e44a9f794e6e7313c7b780b66d58eed8be1
MD5 a64fa0706c34b3a03dbf5a9835b9c680
BLAKE2b-256 d8c10f5ae027dfa95d267118fd10b62164eacd06835c3826158d089e76938423

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page