# Deploy a Bun application on DigitalOcean (/docs/guides/deployment/digital-ocean)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 1558 · updated: 2026-07-28 -->
Related: [Deploy a Bun application on Vercel](/docs/guides/deployment/vercel.md), [Deploy a Bun application on Railway](/docs/guides/deployment/railway.md), [Deploy a Bun application on Render](/docs/guides/deployment/render.md), [Deploy a Bun application on AWS Lambda](/docs/guides/deployment/aws-lambda.md), [Deploy a Bun application on Google Cloud Run](/docs/guides/deployment/google-cloud-run.md)

[DigitalOcean](https://www.digitalocean.com/) is a cloud platform that provides a range of services for building and deploying applications.

This guide deploys a Bun HTTP server to DigitalOcean using a `Dockerfile`.

<Note>
  Before continuing, make sure you have:

  * A Bun application ready for deployment
  * A [DigitalOcean account](https://www.digitalocean.com/)
  * [DigitalOcean CLI](https://docs.digitalocean.com/reference/doctl/how-to/install/#step-1-install-doctl) installed and configured
  * [Docker](https://docs.docker.com/get-started/get-docker/) installed and added to your `PATH`
</Note>

***

<Steps>
  <Step title="Create a new DigitalOcean Container Registry">
    Create a new Container Registry to store the Docker image.

    <Tabs>
      <Tab title="Through the DigitalOcean dashboard">
        In the DigitalOcean dashboard, go to [**Container Registry**](https://cloud.digitalocean.com/registry), and enter the details for the new registry.

        <Frame>
          ![DigitalOcean registry dashboard](/docs/_assets/64697dbe4f951e4ed9b214efdc7e59a6966fc87db1f064563e3f90e51b15149e)
        </Frame>

        Make sure the details are correct, then click **Create Registry**.
      </Tab>

      <Tab title="Through the DigitalOcean CLI">
        ```bash terminal icon="terminal"
        doctl registry create bun-digitalocean-demo
        ```

        ```txt
        Name                     Endpoint                                           Region slug
        bun-digitalocean-demo    registry.digitalocean.com/bun-digitalocean-demo    sfo2
        ```
      </Tab>
    </Tabs>

    You should see the new registry in the [**DigitalOcean registry dashboard**](https://cloud.digitalocean.com/registry):

    <Frame>
      ![DigitalOcean registry dashboard](/docs/_assets/1518c6f06541939d6430fb2ee3f02638e884fae50600073b7e48485688fd1631)
    </Frame>
  </Step>

  <Step title="Create a new Dockerfile">
    Create a new `Dockerfile` in the root of your project. This file contains the instructions to initialize the container, copy your local project files into it, install dependencies, and start the application.

    ```docker Dockerfile icon="docker"
    # Use the official Bun image to run the application
    FROM oven/bun:debian

    # Set the work directory to `/app`
    WORKDIR /app

    # Copy the package.json and bun.lock into the container
    COPY package.json bun.lock ./

    # Install the dependencies
    RUN bun install --production --frozen-lockfile

    # Copy the rest of the application into the container
    COPY . .

    # Expose the port (DigitalOcean will set PORT env var)
    EXPOSE 8080

    # Run the application
    CMD ["bun", "index.ts"]
    ```

    <Note>
      Make sure that the start command corresponds to your application's entry point. This can also be `CMD ["bun", "run", "start"]` if you have a start script in your `package.json`.

      If your app doesn't have dependencies, you can omit the `RUN bun install --production --frozen-lockfile` line.
    </Note>

    Create a new `.dockerignore` file in the root of your project. It lists the files and directories to *exclude* from the container image, such as `node_modules`, which keeps builds faster and smaller:

    ```docker .dockerignore icon="Docker"
    node_modules
    Dockerfile*
    .dockerignore
    .git
    .gitignore
    README.md
    LICENSE
    .vscode
    .env
    # Any other files or directories you want to exclude
    ```
  </Step>

  <Step title="Authenticate Docker with DigitalOcean registry">
    Before building and pushing the Docker image, authenticate Docker with the DigitalOcean Container Registry:

    ```bash terminal icon="terminal"
    doctl registry login
    ```

    ```txt
    Successfully authenticated with registry.digitalocean.com
    ```

    <Note>
      This command authenticates Docker with DigitalOcean's registry using your DigitalOcean credentials. Without this step, the build and push command fails with a 401 authentication error.
    </Note>
  </Step>

  <Step title="Build and push the Docker image to the DigitalOcean registry">
    Make sure you're in the directory containing your `Dockerfile`, then build and push the Docker image to the DigitalOcean registry in one command:

    ```bash terminal icon="terminal"
    docker buildx build --platform=linux/amd64 -t registry.digitalocean.com/bun-digitalocean-demo/bun-digitalocean-demo:latest --push .
    ```

    <Note>
      If you're building on an ARM Mac (M1/M2), you must use `docker buildx` with `--platform=linux/amd64` for compatibility with DigitalOcean's infrastructure. Using `docker build` without the platform flag creates an ARM64 image that won't run on DigitalOcean.
    </Note>

    Once the image is pushed, you should see it in the [**DigitalOcean registry dashboard**](https://cloud.digitalocean.com/registry):

    <Frame>
      ![DigitalOcean registry dashboard](/docs/_assets/4005d827f1e9c48c08e889297df7ad3e9d51129afb59cbf3237aefda568292b0)
    </Frame>
  </Step>

  <Step title="Create a new DigitalOcean App Platform project">
    In the DigitalOcean dashboard, go to [**App Platform**](https://cloud.digitalocean.com/apps) > **Create App**. You can create a project directly from the container image.

    <Frame>
      ![DigitalOcean App Platform project dashboard](/docs/_assets/a60fe932b00432d47a8905eb868e7cadbad769faad86f3ec183515c44a8580f6)
    </Frame>

    Make sure the details are correct, then click **Next**.

    <Frame>
      ![DigitalOcean App Platform service dashboard](/docs/_assets/eb66f7fd5eff5f08a5878bfdb7d5eb8e33307b64478353c2d537ec8ed7274573)
    </Frame>

    Review and configure resource settings, then click **Create app**.

    <Frame>
      ![DigitalOcean App Platform service dashboard](/docs/_assets/52932ae75a76665b5f8f6a4fa15b45097df38b12965f2b411e5f7440cc31aaf1)
    </Frame>
  </Step>

  <Step title="Visit your live application">
    Your app is now live. Once the app is created, you should see it in the App Platform dashboard with its public URL.

    <Frame>
      ![DigitalOcean App Platform app dashboard](/docs/_assets/f3daa883d1d5a56f67da045e235a80734d815922beb00e836a572d55ca81cf77)
    </Frame>
  </Step>
</Steps>
