Skip to content

Bun function

Railway recently introduced functions support based on bun. It allows you to quickly wip up a simple API.

You can achieve the same thing in ZaneOps too leveraging our Config files feature.

You can find a production version of this application at: https://bun-function.fkiss.me

  • A working ZaneOps instance. If you need help with installation, refer to our ZaneOps setup guide.
  1. Create a Docker service using oven/bun image: Creating the bun service

  2. Go to the service settings page and add a new config file with the the mount path of /app/index.ts containing your code: Config file content

    /app/index.ts
    // index.tsx (Bun v1.2 runtime)
    import { Hono } from "hono@4";
    import { cors } from 'hono/cors';
    const app = new Hono();
    app.use("/*", cors());
    app.get("/", (c) => c.text("Hello world!"));
    app.get("/api/health", (c) => c.json({ status: "ok" }));
    Bun.serve({
    port: import.meta.env.PORT ?? 3000,
    fetch: app.fetch,
    });
  3. Update the start command to run the script on startip:

    Terminal window
    bun run /app/index.ts

    Updating the start command

  4. Add a URL to the service Forwarded to the port 3000: Adding a URL to the service

  5. Deploy the service: service successfully deployed