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

# Manually deploy a GitHub project

> Follow each deployment step yourself: download a GitHub project, run its tests, and share it from BoxLite Cloud.

## Choose how to deploy

**Just want your project online? Start with your coding agent.** Give it the [BoxLite agent guide](https://boxlite.ai/agent.md) and your GitHub repository URL. You can copy this prompt:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Read https://boxlite.ai/agent.md and deploy this GitHub project to BoxLite Cloud:
<YOUR_GITHUB_REPOSITORY_URL>

Inspect the project, install its dependencies, run its tests, and start the app.
Verify that it works through its public HTTPS URL, then give me the URL and box ID.
Ask me for any missing Cloud access or project configuration before proceeding.
Keep API keys out of source files and output.
```

You still need a Cloud account, available balance and capacity, and an API key. Follow the agent's requests for access and project-specific configuration. The guide provides deployment instructions; the agent performs the steps for your project.

**Want to run each command yourself? Continue with this manual tutorial.** You will deploy [Flask's official Flaskr example](https://github.com/pallets/flask/tree/80be49be88b534d2a72ef6bf5ea4aabf89f3305b/examples/tutorial): a small blog with registration, sign-in, and editable posts. By the end, you will have a public HTTPS URL that remains usable after you close your local terminal.

You do not need to write application code or install Python, Docker, or Git on your computer. The app's dependencies and SQLite database live inside the Cloud box.

## Before you begin

You need a macOS or Linux computer, a Bash or Zsh terminal, curl, and an internet connection. This walkthrough was tested on macOS; Windows and WSL were not tested.

A **box** is your isolated Linux environment in the cloud. The CLI on your computer creates the box, runs commands inside it, and retrieves its public URL.

In the [BoxLite console](https://app.boxlite.ai):

1. Sign up or sign in and select an organization. Keep the same organization selected throughout: it owns your boxes, API keys, and billing.
2. Open **Management → Billing** or **Wallet**. Confirm you have available usage balance, capacity for **1 CPU, 1 GiB of memory, and 4 GB of requested disk**, and one free running-box slot. If needed, add balance or choose a plan using the account page. This tutorial does not require automatic top-ups. See [Plans and limits](https://docs.boxlite.ai/cloud/plans.md).
3. Open **API Keys → New API key**. Name it `flaskr-workshop`, choose **Manage box lifecycle** under **Access**, select an expiration that covers this tutorial, and click **Create API key**. The default **Operate boxes** access does not include the deletion permission needed for cleanup.
4. Copy and save the full key while it is displayed. The masked value in the key list cannot be used to sign in.

> [!NOTE]
>
> Run every command below in your **local terminal**. Commands beginning with `boxlite exec` run the program that follows inside the cloud box. Keep your API key private; app visitors only need the HTTPS link.

## 1. Install the CLI and connect

Install the official CLI:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -fsSL https://sh.boxlite.ai | sh
export PATH="$HOME/.local/bin:$PATH"
boxlite --version
```

Once the version command succeeds, sign in to Cloud:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop auth login --url https://api.boxlite.ai --method api-key
```

Paste your full API key when prompted and press Enter. Input may be hidden. `workshop` is the name of the connection saved on your computer. Every command explicitly uses this context to target the same environment.

The API endpoint is `https://api.boxlite.ai`, not the console URL. Verify your connection:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop auth whoami
boxlite --context workshop list
```

The identity check should succeed and the box list should return normally. An empty list also means the connection works. Resolve authentication errors before creating a box.

## 2. Create a box

Create a box named `flaskr-workshop` using an image with Python installed. First check that your list contains no box with this name. If it does, choose a different name and replace it throughout the commands below.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop create \
  --name flaskr-workshop \
  --cpus 1 --memory 1024 --disk-size 4 \
  --inbound enabled --auto-stop 6h --auto-delete 0 \
  --entrypoint sh python:3.12-slim -- -c \
  'while [ ! -f /workspace/start.py ]; do sleep 1; done; exec python -u /workspace/start.py'

boxlite --context workshop start flaskr-workshop
```

The create command prints a box ID. After startup succeeds, you can find `flaskr-workshop` under **Boxes** in the console.

The box requests 1 CPU, 1024 MiB of memory, and 4 GB of disk. `--inbound enabled` allows access to the web service you will register later. `--auto-stop 6h` sets the idle-stop threshold; `--auto-delete 0` keeps the box until you delete it.

The startup command waits for `/workspace/start.py`, then runs it. You will create that file in step 4. The same saved command runs whenever the box starts again. See [Box lifecycle](https://docs.boxlite.ai/cloud/box-lifecycle.md) for the lifecycle settings.

## 3. Download, install, and test the app

Download the source from a fixed GitHub commit. Python inside the box downloads and extracts the archive; you do not need a GitHub token or local checkout.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop exec flaskr-workshop -- python -c '
import io
import pathlib
import tarfile
import urllib.request
revision = "80be49be88b534d2a72ef6bf5ea4aabf89f3305b"
url = "https://codeload.github.com/pallets/flask/tar.gz/" + revision
workspace = pathlib.Path("/workspace")
workspace.mkdir(exist_ok=True)
archive = urllib.request.urlopen(url, timeout=60).read()
with tarfile.open(fileobj=io.BytesIO(archive), mode="r:gz") as source:
    source.extractall(workspace, filter="data")
print("GitHub source ready:", revision)
'
```

After `GitHub source ready:` appears, install the dependencies:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop exec \
  -w /workspace/flask-80be49be88b534d2a72ef6bf5ea4aabf89f3305b/examples/tutorial \
  flaskr-workshop -- python -m pip install \
  flask==3.1.2 pytest==8.4.2 waitress==3.0.2
```

The `-w` option sets the working directory inside the box. Flask is the application framework, pytest runs the tests, and Waitress serves the web app.

Once installation succeeds, run the example's tests:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop exec \
  -w /workspace/flask-80be49be88b534d2a72ef6bf5ea4aabf89f3305b/examples/tutorial \
  flaskr-workshop -- python -m pytest -q
```

Expected output:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
........................                                                 [100%]
24 passed in ...s
```

Continue after you see `24 passed`. If downloading, installing, or testing fails, resolve that error and retry the relevant step; you do not need a new box. These tests use a separate test database, so you can run them again later without clearing your blog posts.

## 4. Initialize the database and start the app

> [!WARNING]
>
> Run the database initialization command **only once**. Running it again deletes existing application accounts and posts and replaces the session secret. Do not repeat it to restart the service or rerun tests.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop exec \
  -w /workspace/flask-80be49be88b534d2a72ef6bf5ea4aabf89f3305b/examples/tutorial \
  flaskr-workshop -- python -c '
from pathlib import Path
import secrets
from flaskr import create_app
from flaskr.db import init_db
app = create_app()
config = Path(app.instance_path) / "config.py"
config.write_text("SECRET_KEY = " + repr(secrets.token_hex(32)))
with app.app_context():
    init_db()
print("Database initialized")
'
```

After `Database initialized` appears, write the startup file:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop exec flaskr-workshop -- python -c '
from pathlib import Path
startup = """import sys
from waitress import serve
sys.path.insert(0, "/workspace/flask-80be49be88b534d2a72ef6bf5ea4aabf89f3305b/examples/tutorial")
from flaskr import create_app
serve(create_app(), host="0.0.0.0", port=3000)
"""
Path("/workspace/start.py").write_text(startup)
print("Startup file ready")
'
```

Once you see `Startup file ready`, the command saved in step 2 starts the app automatically. The file loads Flaskr and serves it through Waitress on `0.0.0.0:3000`. You do not need to keep your local terminal open.

## 5. Open and share your app

Create an HTTPS access URL for port 3000:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop network tunnel flaskr-workshop 3000
```

Copy the full `https://…proxy.boxlite.ai` URL returned by your command and open it in your browser. If a preview notice appears, follow its instructions. If the app is still starting, wait briefly and refresh.

You should see the **Flaskr** homepage. Try the complete flow:

1. Click **Register** and create an account with a fictional username and a password used only for this demo.
2. **Log In**, click **New**, enter a title and body, and click **Save**.
3. Refresh the page and confirm your post is still there. Click **Edit**, change the body, and save again.
4. **Log Out** and confirm you can still read the post.

> [!TIP]
>
> Your GitHub app is now running on BoxLite Cloud. Share its HTTPS URL: visitors do not need a BoxLite account or API key. To publish posts, they register an account in Flaskr itself.

This example is publicly accessible. Use demo data only. See [Tunnels](https://docs.boxlite.ai/cloud/tunnels.md) for details about the access URL.

### Come back to the same URL

You do not need to redeploy or open a terminal before each visit. This tutorial keeps the default **Wake on access** behavior. When the box stops after being idle, its code and database stay on disk. Visiting the registered HTTPS URL wakes the box, and the saved startup command starts Flaskr again. The first request may take longer.

`6h` is an idle-stop threshold, not the URL's lifetime or a spending cap. Automatic wake requires the box to exist, Wake on access to remain enabled, a registered port, a valid startup command, and available account balance and capacity. See [Box lifecycle](https://docs.boxlite.ai/cloud/box-lifecycle.md).

If you lose the URL, run the same `network tunnel` command again. Do not initialize the database again to recover access.

## 6. Clean up when you are done

To keep using the app, retain the box and monitor usage in Billing. Stopped disk storage can still incur charges. Closing your terminal or revoking your API key does not delete the box.

> [!WARNING]
>
> The following command deletes the box, including its code and database. Save any posts you want to keep first.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop rm -f flaskr-workshop
boxlite --context workshop list
```

Confirm that `flaskr-workshop` no longer appears in the list. Its old URL can no longer serve the app. If the list request fails, retry or verify deletion in the console. Delete only the box created for this tutorial.

If the API key was only for this tutorial, open **API Keys** in the console, find `flaskr-workshop`, and choose **Revoke key**. Confirm revocation, then clear the local credentials:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop auth logout
```

Confirm when prompted. If you stop partway through the tutorial, clean up any box you created. See [Usage and costs](https://docs.boxlite.ai/cloud/box-costs.md).

## Troubleshooting

| Symptom | What to do |
| - | - |
| `boxlite: command not found` | Repeat the `export PATH` command and check the installer output. You may need to set PATH again in a new terminal. |
| `401` or `403` | Check the full key, expiration, organization permissions, and API endpoint. If only deletion fails, confirm **Manage box lifecycle** access. |
| Insufficient balance or capacity | Check Billing, resource capacity, and running-box slots in the same organization. |
| GitHub or pip download fails | Resolve the network error and retry that step without recreating the box. |
| `WS connect failed` or `503` | Wait briefly and check box status. Do not repeat database initialization if you are unsure whether it already completed. |
| Tests fail | Read the pytest output and resolve failures before starting and sharing the app. |
| The URL cannot reach the app | Check the startup file, registered port 3000, Wake on access, and account balance. Use the diagnostic commands below. |
| Blog sign-in fails | Use the account you registered in Flaskr, not your BoxLite account or API key. |
| Posts disappear | Check whether you initialized the database again or deleted and recreated the box. This tutorial does not configure backups. |

Only if access fails, inspect the box and try starting it manually:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
boxlite --context workshop inspect flaskr-workshop
boxlite --context workshop start flaskr-workshop
```

These commands are for diagnosis, not a prerequisite for each visit. If manual startup works but automatic wake does not, check Wake on access, the registered port, and account status. Never use database initialization to repair access.

When asking for help, include the failing step, CLI version, box ID, and error text. Do not include your full API key.

## Deploy your own project next

You have completed the full path: create an environment, download code, install dependencies, test, start, and share. For your own project, replace the image, source URL, working directory, dependency and test commands, startup file, and service port.

This example pins the source commit and direct dependencies, but does not fully lock the base image or transitive dependencies. It is an introductory deployment, not a production security, backup, or load-testing checklist.

> [card] [Serve HTTP](https://docs.boxlite.ai/cloud/serve-http.md)
>
> Configure the startup command and port for your own web service.

> [card] [Box lifecycle](https://docs.boxlite.ai/cloud/box-lifecycle.md)
>
> Choose when your app stops, wakes, and is deleted.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.