> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ollie.shop/llms.txt
> Use this file to discover all available pages before exploring further.

# Deployment

> Deploy your functions to Ollie Hub with instant builds, real-time monitoring, and automatic scaling. From code upload to live function in under 60 seconds.

{/* 
Deployment Process Keywords: function deployment, build process, TypeScript compilation, dependency installation, function activation, build status, function status

Technical Deployment Flow:
1. Project folder upload (drag and drop)
2. Automatic build process (dependencies, compilation, bundling)
3. Global infrastructure deployment  
4. Manual function activation (inactive -> active)
5. Live traffic handling and monitoring

Required Files and Structure:
- index.ts: Main function file with exported handler
- package.json: Dependencies and project metadata
- Optional: lib/ directory for additional modules
- Handler export pattern: export const handler = async (event: any) => {}

Build System Details:
- Language support: TypeScript, JavaScript
- Package management: npm dependency installation
- Compilation: TypeScript to optimized JavaScript
- Deployment target: global serverless infrastructure
- Build time: typically 30-60 seconds
- Status tracking: real-time build progress

Build Status vs Function Status (Important Distinction):
- Build Status: IN_PROGRESS, SUCCEEDED, FAILED, STOPPED (deployment process)
- Function Status: ACTIVE, INACTIVE (traffic handling state)
- Key point: Successful build creates INACTIVE function requiring manual activation

Common Deployment Issues:
1. Dependencies failed to install: package.json errors, invalid versions
2. TypeScript compilation errors: syntax errors, type mismatches  
3. Missing entry point: no handler export in index.ts
4. Concurrent builds: only one build allowed per function at a time

Activation Requirements:
- Functions deploy as INACTIVE by default
- Manual activation required via "Activate Function" button
- Only ACTIVE functions handle live traffic
- Users can toggle between ACTIVE/INACTIVE states

Troubleshooting Context:
- Build logs show real-time progress and errors
- Common fixes: check package.json syntax, verify TypeScript code
- Concurrent build protection prevents conflicts
- 409 error when build already in progress

Best Practices:
- Test locally before deployment
- Keep dependencies minimal for faster builds
- Include proper error handling
- Use TypeScript for type safety
- Monitor performance after activation

Related Concepts: function types, Hub integrations, trigger patterns, monitoring, performance optimization
*/}

Deploy your functions instantly with zero infrastructure setup. Upload your code and watch it build in real-time while we handle all the complexity behind the scenes.

<CardGroup cols={2}>
  <Card title="Instant Deployment" icon="bolt">
    **From code to live function in under 60 seconds**

    Upload your project folder and watch real-time build progress. No configuration, no setup, just working functions.
  </Card>

  <Card title="Smart Build System" icon="gear">
    **Intelligent dependency management**

    Automatic package installation, TypeScript compilation, and optimization for maximum performance.
  </Card>
</CardGroup>

## How Deployment Works

<Steps>
  <Step title="Upload Your Code">
    **Drag and drop your project folder**

    Upload your project folder containing your function code and `package.json`. We support TypeScript, JavaScript, and all popular npm packages.

    ```bash theme={"system"}
    your-function/
    ├── index.ts          # Your function code with handler export
    ├── package.json      # Dependencies and metadata
    └── lib/             # Additional modules (optional)
        └── utils.ts
    ```

    <Note>
      Your folder must contain `index.ts` and `package.json`. The `index.ts` file must export a `handler` function.
    </Note>
  </Step>

  <Step title="Automatic Build Process">
    **Watch your function build in real-time**

    Our build system automatically:

    * Installs all npm dependencies
    * Compiles TypeScript to optimized JavaScript
    * Bundles your code for maximum performance
    * Deploys to our global infrastructure

    ```bash theme={"system"}
    ⏳ Build Started...
    📦 Installing dependencies...
    🔨 Compiling TypeScript...
    📋 Bundling application...
    🚀 Deploying to production...
    ✅ Function is live!
    ```

    <Info>
      The entire process typically takes 30-60 seconds. You'll see real-time updates for each step.
    </Info>
  </Step>

  <Step title="Activate Your Function">
    **Enable your function to handle requests**

    After deployment completes successfully, click **"Activate Function"** to make it live and ready to handle requests.

    <Warning>
      **Activation Required**: Functions are deployed but inactive by default. You must activate them to start receiving traffic.
    </Warning>
  </Step>

  <Step title="Test Your Function">
    **Test your function immediately**

    Once activated, your function is live and ready to handle requests. Test it directly from the dashboard.

    ```json theme={"system"}
    // Test your function with custom payloads
    {
      "queryStringParameters": {
        "name": "Ollie Hub",
        "action": "test"
      }
    }
    ```
  </Step>
</Steps>

## Build Status Monitoring

Track your deployment with comprehensive status indicators:

<Tabs>
  <Tab title="Build States">
    | Status              | Description                  | What's Happening                        |
    | ------------------- | ---------------------------- | --------------------------------------- |
    | **🔄 IN\_PROGRESS** | Build is actively running    | Dependencies installing, code compiling |
    | **✅ SUCCEEDED**     | Build completed successfully | Function deployed, ready for activation |
    | **❌ FAILED**        | Build encountered an error   | Check logs for specific error details   |
    | **⏹️ STOPPED**      | Build was manually stopped   | Build was cancelled or interrupted      |
  </Tab>

  <Tab title="Build Timeline">
    **Typical build progression:**

    ```bash theme={"system"}
    00:05 - Build initiated
    00:10 - Folder uploaded and validated
    00:15 - Installing npm dependencies
    00:35 - Compiling TypeScript
    00:45 - Bundling and optimizing
    00:55 - Deploying to infrastructure
    01:00 - Build complete, ready for activation ✅
    ```

    <Note>
      Build times vary based on dependency count and code complexity. Most builds complete in under 60 seconds.
    </Note>
  </Tab>

  <Tab title="Function Status">
    **Function status is separate from build status:**

    | Status          | Description                                    | Action Available    |
    | --------------- | ---------------------------------------------- | ------------------- |
    | **🟢 ACTIVE**   | Function is live and handling requests         | Deactivate function |
    | **🔴 INACTIVE** | Function is deployed but not receiving traffic | Activate function   |

    <Info>
      After a successful build, your function starts as **INACTIVE**. Click "Activate Function" to make it live.
    </Info>
  </Tab>
</Tabs>

## Concurrent Build Protection

We automatically prevent conflicting deployments to ensure stability:

<Warning>
  **One Build at a Time**

  If you try to deploy while a build is already in progress, you'll receive a `409 Conflict` response. Wait for the current build to complete before starting a new one.
</Warning>

```json theme={"system"}
// Error response when build is already running
{
  "error": "A build is already in progress for this function",
  "details": {
    "buildId": "current-build-id",
    "startTime": "2024-01-15T10:30:00.000Z"
  }
}
```

## Troubleshooting Builds

Common issues and how to resolve them:

<Accordion title="🔴 Dependencies Failed to Install">
  **`Check your package.json for issues:`**

  ```json theme={"system"}
  {
    "name": "my-function",
    "version": "1.0.0",
    "dependencies": {
      "axios": "^1.6.0",
      "zod": "^3.22.0"
    }
  }
  ```

  **Common problems:**

  * Misspelled package names
  * Invalid version specifications
  * Private packages without authentication
  * Packages that require native compilation

  **Solution:** Verify all package names and versions exist on npm registry.
</Accordion>

<Accordion title="🟡 TypeScript Compilation Errors">
  **Check for syntax and type errors:**

  ```typescript theme={"system"}
  // ❌ This will cause compilation to fail
  export const handler = async (event: any) => {
    return event.invalidProperty.doesNotExist;
  };

  // ✅ This compiles successfully
  export const handler = async (event: any) => {
    return {
      statusCode: 200,
      body: JSON.stringify({ message: "Hello World" })
    };
  };
  ```

  **Solution:** Fix TypeScript errors in your code before uploading.
</Accordion>

<Accordion title="🟣 Missing Entry Point">
  **Ensure your function exports a handler:**

  ```typescript theme={"system"}
  // ✅ Correct entry point in index.ts
  export const handler = async (event: any) => {
    // Your function logic here
    return {
      statusCode: 200,
      body: JSON.stringify({ success: true })
    };
  };
  ```

  **Solution:** Export a `handler` function from your main file.
</Accordion>

## Deployment Best Practices

<CardGroup cols={2}>
  <Card title="Optimize Dependencies" icon="box">
    **Keep your builds fast**

    Only include necessary dependencies in `package.json`. Remove unused packages to reduce build time and function size.
  </Card>

  <Card title="Handle Errors Gracefully" icon="shield">
    **Always return proper responses**

    Include try-catch blocks and return appropriate HTTP status codes for all scenarios.
  </Card>

  <Card title="Test Locally First" icon="bug">
    **Catch issues before deployment**

    Use TypeScript compiler and test your function logic locally before uploading.
  </Card>

  <Card title="Monitor Performance" icon="chart-line">
    **Watch your function metrics**

    Use the dashboard to monitor execution time, memory usage, and error rates after deployment.
  </Card>
</CardGroup>

## Ready to Deploy?

<CardGroup cols={2}>
  <Card title="Deploy Your First Function" icon="rocket" href="/ollie-hub/getting-started/quickstart">
    **Follow our quickstart guide**

    Step-by-step instructions to get your first function deployed and running.
  </Card>

  <Card title="Function Examples" icon="code" href="/ollie-hub/core-concepts/functions">
    **See real-world examples**

    Browse working code samples for common use cases and integration patterns.
  </Card>
</CardGroup>
