|Docs

Deploy a Bun App

deploymentbunjavascriptbackend

Bun is a fast all-in-one JavaScript runtime and toolkit designed as a drop-in replacement for Node.js.

This guide covers how to deploy a Bun app on Railway in four ways:

  1. One-click deploy from a template.
  2. From a GitHub repository.
  3. Using the CLI.
  4. Using a Dockerfile.

One-click deploy from a template

Deploy on Railway

It is highly recommended that you eject from the template after deployment to create a copy of the repo on your GitHub account.

Note: You can also choose from a variety of Bun templates created by the community.

Deploy from a GitHub repo

To deploy a Bun app on Railway directly from GitHub, follow the steps below:

  1. Create a New Project.
  2. Click Deploy from GitHub repo.
  3. Select your Bun GitHub repo.
    • Railway requires a valid GitHub account to be linked. If your Railway account isn't associated with one, you will be prompted to link it.
  4. Click Deploy Now.

Note: Railpack does not yet detect Bun projects automatically. Add a Dockerfile to your repo for Railway to build and deploy your app.

Once the deployment is successful, a Railway service will be created for you. By default, this service will not be publicly accessible.

To set up a publicly accessible URL for the service, navigate to the Networking section in the Settings tab of your new service and click on Generate Domain.

Deploy from the CLI

  1. Install and authenticate with the CLI.
  2. cd into your Bun app directory.
  3. Run railway init within the app directory to create a new project.
  4. Run railway up to deploy.

Note: Railpack does not yet detect Bun projects automatically. Add a Dockerfile to your repo for Railway to build and deploy your app.

Use a Dockerfile

  1. Create a Dockerfile in your app's root directory.

  2. Add the content below to the Dockerfile:

  3. Either deploy via the CLI or from GitHub.

Railway automatically detects the Dockerfile, and uses it to build and deploy the app.

Note: Railway supports also deployment from public and private Docker images.

Next steps

Explore these resources to learn more about Railway: