Bun function
Introduction
Section titled “Introduction”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.
Live demo
Section titled “Live demo”You can find a production version of this application at: https://bun-function.fkiss.me
Prerequisites
Section titled “Prerequisites”- A working ZaneOps instance. If you need help with installation, refer to our ZaneOps setup guide.
Process
Section titled “Process”-
Create a Docker service using
oven/bunimage:
-
Go to the service settings page and add a new config file with the the mount path of
/app/index.tscontaining your code:
/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,}); -
Update the start command to run the script on startip:
Terminal window bun run /app/index.ts
-
Add a URL to the service Forwarded to the port
3000:
-
Deploy the service:
