CTRLctrl docs

Deploy from GitHub

Connect a GitHub repo and CTRL builds it into a microVM. After the first deploy, every push to the branch you picked deploys again on its own.

Connect GitHub#

You sign in to CTRL with GitHub, and that sign-in is the connection. CTRL asks GitHub for the read:user and repo scopes, so it can list your repos, clone them, and add a webhook to each repo you deploy.

If the deploy page says "Sign out and sign back in to connect your GitHub repos.", your account has no GitHub token yet. Sign out and sign back in. The API gives the same advice when the token is missing or has expired:

  • GitHub not connected -- sign out and sign back in to grant repo access
  • GitHub token expired -- sign out and sign back in

Pick a repo and a branch#

  1. Open deploy in the dashboard.
  2. Type in Search repos.... CTRL lists the repos your GitHub account owns, up to 50, most recently pushed first, and filters them by name as you type.
  3. Click a repo. The panel beside the list opens.
  4. Pick a branch. It starts on the repo's default branch.
  5. Check the Dockerfile line. It says Dockerfile found, or that CTRL will detect your stack instead. See Builds for both cases.
  6. Set the region, app name, size, exposed port and any env vars, then click deploy.

The exposed port is the port your app listens on. It starts at 8080. Your app must listen on all interfaces (0.0.0.0), not only on 127.0.0.1.

The deploy screen shows the build output as it happens. When it says "deploy finished. Your app is live.", click view app.

Your app gets an id made from your GitHub login, the repo name and the branch, for example octocat-my-api-main, and a URL at https://<app_id>.getctrl.dev.

With the API#

The dashboard uses these routes, and you can call them with an API key:

Route What it does
GET /v1/github/repos Lists your repos: full_name, name, private, default_branch, language, pushed_at
GET /v1/github/repos/:owner/:repo/branches Lists a repo's branches, up to 50
GET /v1/github/repos/:owner/:repo/dockerfile?ref=<branch> Returns { "exists": true } if there is a Dockerfile at the repo root. Without ref it checks main
POST /v1/apps Deploys the repo

To deploy a repo, send repo_url and leave out image_ref:

curl -X POST https://api.getctrl.dev/v1/apps \
  -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-api",
    "repo": "my-api",
    "branch": "main",
    "repo_url": "https://github.com/octocat/my-api.git",
    "region": "us-east",
    "exposed_port": 8080,
    "cpu_millis": 500,
    "mem_size_mb": 1024,
    "disk_size_mb": 10240,
    "env_vars": [["NODE_ENV", "production"]]
  }'

repo_url must be https://github.com/<owner>/<repo>, with or without .git. Anything else gets repo_url must be https://github.com/<owner>/<repo>.

A deploy that takes longer than the request answers 202. Poll GET /v1/apps/:app_id until status is running. A 404 there means the first deploy failed, and the error says why.

Push to deploy#

When your first deploy succeeds, CTRL adds a webhook to the repo for push, delete and pull_request events. You don't need to set anything up in GitHub.

From then on, each push to the app's branch builds and deploys that exact commit. The new deploy shows on the app's deploys tab with the trigger push, the commit and the first 200 characters of its message.

The old VM keeps serving until the new build is ready. If a push can't deploy, for example because your blocks are full, the deploy is listed as failed with the reason.

Adding the webhook is best effort. If GitHub refuses it, for example because your account can't manage hooks on that repo, the app still deploys, but pushes won't redeploy it. You can still redeploy by hand:

ctrl deploy my-app

Or with the API: POST /v1/apps/:app_id/redeploy. Both rebuild the branch with the app's current env vars.

To go back to an earlier commit, use Roll back on the deploys tab, ctrl rollback <app>, or POST /v1/apps/:app_id/rollback. See Lifecycle.

Branch previews#

A push to a branch that has no app of its own creates a preview of that branch, when the repo already has an app in your default project's production environment.

A preview:

  • copies its parent app's size, exposed port, env vars and region
  • gets its own app id from your login, the repo and the branch, and a URL at https://<app_id>.getctrl.dev
  • is named <repo> (<branch>)
  • redeploys on each later push to its branch
  • never gets the parent's volume, so it can't touch production data, and can't have a volume of its own
  • runs one copy only

A preview is deleted when its branch is deleted, or when a pull request from that branch in the same repo is closed or merged. A pull request from a fork doesn't remove a preview.

Each preview uses blocks like any other app. You can have at most 5 previews at once. When a preview can't be created, because you are at the limit or out of blocks, no preview appears. Delete a branch to free a slot.

Next#

  • Builds: how CTRL builds your repo, and how to fix a failed build.
  • Logs and metrics: follow a build and your running app.