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

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Deploy a Deno application

> Deploy a Deno 2 HTTP server to Sevalla from a Git repository with a Dockerfile based on the official denoland/deno image, reading the PORT variable.

A Deno server runs on Sevalla as an application built from a Dockerfile: the official `denoland/deno` image provides the Deno version you pin, and the web process runs `Deno.serve()` on the port that Sevalla sets in the `PORT` environment variable.

Sevalla's default build strategy, Nixpacks, detects `deno.json` too, but Nixpacks 1.41 installs Deno 1.36, which can't run Deno 2 projects. The Dockerfile in this guide pins Deno 2.9.7.

## Before you begin

* A Sevalla company with a payment method, and a GitHub, GitLab or Bitbucket account for the repository. See [Git providers](/git/overview).
* Deno 2 on your computer.

## Create the project

Create a project with `deno init`:

```bash theme={null}
deno init storefront
cd storefront
```

Replace `main.ts` with a server, and delete `main_test.ts`, which tests the starter's example function:

```ts main.ts theme={null}
const port = Number(Deno.env.get("PORT") ?? 8000);

Deno.serve({ port, hostname: "0.0.0.0" }, () => {
  return new Response("Hello from Deno on Sevalla");
});
```

Add a `start` task to `deno.json` for running the server locally:

```json deno.json theme={null}
{
  "tasks": {
    "start": "deno run --allow-net --allow-env main.ts"
  }
}
```

Keep the other fields that `deno init` wrote.

## Prepare the project for Sevalla

The server already handles the port: it reads [`PORT`](/guides/javascript/overview#listen-on-the-port-environment-variable), which Sevalla sets to the web process's port (`8080` by default), and listens on `0.0.0.0`, all network interfaces. Reading `PORT` needs the `--allow-env` permission, and serving requests needs `--allow-net`.

Create a Dockerfile in the repository root:

```dockerfile Dockerfile theme={null}
FROM denoland/deno:2.9.7

WORKDIR /app

COPY . .
RUN deno cache main.ts

USER deno

CMD ["deno", "run", "--allow-net", "--allow-env", "main.ts"]
```

* `deno cache` downloads and compiles the dependencies during the build, so instances don't fetch them when they start.
* `USER deno` runs the server as the image's unprivileged user.
* `CMD` is the web process's start command. To run another command without changing the Dockerfile, set a **Custom start command** on the web process (see [Processes](/applications/processes)).

Run `deno task start` and open `http://localhost:8000` to check the server locally. Then commit everything and push it to your Git provider:

```bash theme={null}
git init
git add .
git commit -m "Prepare for Sevalla"
git branch -M main
git remote add origin https://github.com/acme/storefront.git
git push -u origin main
```

## Deploy to Sevalla

<Steps>
  <Step title="Create the application">
    In the sidebar, click **Applications**, then click **Create** > **Application**. Under **Source**, click **Private repository**, then choose the **Git provider**, the **Repository** and the **Branch**. Under **Location**, choose a **Data center**. Keep the **Size** at **H1** or choose a larger one, then click **Create application**. The application opens on its **Overview** tab with the status **Not deployed yet**: creating an application doesn't deploy it.
  </Step>

  <Step title="Set the build strategy">
    Click the **Settings** tab, then click **Update build strategy**. Choose **Dockerfile**, keep the **Dockerfile path** at `Dockerfile` and the **Docker context** at `.`, and click **Update build strategy**.
  </Step>

  <Step title="Deploy">
    Click the **Overview** tab, then click **Deploy now** under **Recent deployments**. Check the **Branch** and click **Deploy**.
  </Step>

  <Step title="Turn on auto-deploy">
    To deploy every push to the branch automatically, click the **Settings** tab, then click **Update auto-deploy** in the **Auto-deploy** section. Turn on **Auto-deploy** and click **Update auto-deploy**. See [Deployments](/applications/deployments#deploy-automatically-on-push).
  </Step>
</Steps>

## Verify the deployment

1. On the **Deployments** tab, wait for the deployment's status to change to **Deployed**. The application's status next to its name changes to **Running**.
2. Click the domain under the application's name, for example `storefront-x7k2m.sevalla.app`. The page shows `Hello from Deno on Sevalla`.

<Frame>
  <img className="block dark:hidden" src="https://assets.sevalla.com/screenshots/light/app-overview-address.png" alt="The application header with its name, Running status, repository, branch and the domain that opens the application" width="1192" />

  <img className="hidden dark:block" src="https://assets.sevalla.com/screenshots/dark/app-overview-address.png" alt="The application header with its name, Running status, repository, branch and the domain that opens the application" width="1192" />
</Frame>

If the deployment fails, open it on the **Deployments** tab and read its build log, then see [Troubleshoot builds and deployments](/applications/troubleshooting/builds-and-deployments). A build log that mentions Nixpacks means the build strategy is still Nixpacks. If the server stops with a `NotCapable` error in the [runtime logs](/applications/logs), add the permission it names to the `CMD` line.

## Deploy changes

With **Auto-deploy** on, every push to the branch starts a deployment; otherwise, click **Deploy now** for each change. Each deployment builds the image, then replaces the web process's instances. See [Deployments](/applications/deployments).

## Use environment variables

Add configuration on the application's **Environment variables** tab and read it with `Deno.env.get()`. A Dockerfile build receives variables marked **Available during buildtime** as [build arguments](/applications/builds/dockerfile#use-build-arguments), so the Dockerfile needs an `ARG` line for each one it uses during the build. Variables apply at the next deployment. See [Environment variables](/applications/environment-variables).

## Add a custom domain

To serve the application from your own domain, such as `shop.example.com`, add the domain on the application's **Domains** tab and create the DNS records that Sevalla shows. Custom domains need a web process larger than **H1**, so [scale](/applications/scaling) the web process first. See [Custom domains](/domains/overview).


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