Serverless output format

Serverless Output Format

Zeabur supports both containerized and serverless deployment. When you deploy your project to Zeabur, Zeabur will use zbpack (opens in a new tab) to analyze and build your project automatically. You can find more information about the build process in Builds.

Containerized deployment requires more computing resources, because even if the service is not in use, it needs to be kept open to maintain various internal states of the service. The serverless deployment method decomposes the service into multiple serverless functions that can be used immediately. When the service receives an external request, it executes the function to calculate and return the result, thereby providing higher scalability and saving unnecessary costs.

Build Output Format

Without any additional configuration, zbpack will choose whether to use the serverless method based on the development framework used by the project. If zbpack decides to use the serverless method for building, you can find the .zeabur/output directory in the project directory after the build is completed. The structure under the directory is as follows:

├── static
│   ├── index.html
│   └── ...
├── functions
│   ├── index.func
│   └── ...

The static directory stores static resources such as HTML, CSS, JavaScript, etc., and the functions directory stores serverless functions. Each directory ending with .func is a function entry, and they correspond to a path after the service is deployed online, for example:

  • functions/index.func corresponds to the path /
  • functions/users/get.func corresponds to the path /users/get
  • functions/api/orders.func corresponds to the path /api/orders
  • functions/api/orders/[id].func corresponds to the path /api/orders/[id], where [id] is a dynamic path that can match any path.

To maximize the compatibility of the build output, zbpack's serverless build output format is as consistent as possible with Vercel (opens in a new tab)'s Build Output API (v3) (opens in a new tab). In this way, the authors and teams of existing frameworks or new frameworks in the future do not need to re-develop adapters for different platforms.

Pure Static Output

For purely static website frameworks, such as Vite (opens in a new tab), etc., there will only be a static directory in the .zeabur/output directory after zbpack is built, and there is no functions directory. This is because purely static website frameworks do not need to use the serverless method for deployment, so zbpack will directly package all static resources into the static directory, and directly deploy the resources in the static directory to the CDN during deployment.

Serverless Functions

For frameworks that need to use Serverless, such as Next.js (opens in a new tab) or Nuxt.js (opens in a new tab), etc., there will be two directories, static and functions, in the .zeabur/output directory after zbpack is built. The static directory stores static resources, and the functions directory stores serverless functions.

For services deployed on Zeabur, you can see whether they are currently deployed using the serverless method or the containerized method in the upper right corner of the service details page: