Zum Inhalt springen
GigadriveDocs

Entrypoints

The functions block turns files into Functions and sets what each one gets, from runtime and memory to its duration ceiling and packaged files.

Every key in the functions block is a file pattern, and every file it matches becomes its own Function. The value is the settings that Function runs with.

Declaring a Function

version: 4

functions:
  api/index.js:
    runtime: node-22
    memory: 512
    max_duration: 60

The key is the file path relative to the project root, with no leading slash. A route's destination repeats that string exactly, which is how Routes point traffic at it. A Function nothing routes to is still packaged and deployed, but no request reaches it.

Patterns

A key is tried as a glob first. If it is not the name of a file that exists, it is tried again as a regular expression anchored at both ends, so api/.*\.js and api/** both work. A pattern that matches nothing is not an error: it produces no Function and the build carries on.

functions:
  api/**:
    runtime: node-22
    memory: 256
  api/report.js:
    memory: 1024

Each file under api/ becomes a separate Function at 256 MB. api/report.js gets 1024 MB and still inherits runtime: node-22, because settings merge across every pattern that matches a file, with later blocks winning. Naming the file exactly also decides which block owns it, and two settings depend on that.

Settings

KeyTypeAcceptedDefault
runtimestringOne of eight identifiersnode-20
memorynumber, MB128 to 3009128
max_durationnumber, seconds1 to 2880030
includeFilesstring or list of stringsGlob patternsnone
excludeFilesstring or list of stringsGlob patternsnone
symlinksmap1 to 100 entries, each side 256 characters at mostnone
schedulestringA rate or cron expressionnone

Runtimes lists the eight identifiers and what each one expects from your code. Memory and CPU covers what the platform does with a memory figure, and Max duration covers what the duration ceiling bounds. A Function that runs on a timer instead of a request is described in Cron jobs.

Which files get packaged

A Node or Bun Function is packaged from its dependency graph, traced from the entry file. That misses files your code opens at runtime through a path it computes, which is what includeFiles is for: those globs are added after tracing. excludeFiles removes files from the traced set, and it also removes them from the pattern match itself, so it can stop a file from becoming a Function at all.

functions:
  api/report.js:
    runtime: node-22
    includeFiles:
      - templates/**
      - data/rates.json
    excludeFiles: '**/*.test.js'

symlinks creates links in the project directory at build time, before the Function is packaged, for code that insists on finding a directory at a fixed path. The key is where the link is created, relative to the project root. The value is what it points at, resolved relative to the link's own directory.

functions:
  public/index.php:
    runtime: php-84
    symlinks:
      public/storage: ../storage/app/public

Both ends have to resolve inside the project root. An absolute target such as /tmp/cache never does: that entry is skipped, the deployment log records Symlink target /tmp/cache for source public/storage is not valid, and the deployment carries on without the link. Anything already sitting at the key path is removed first.

Settings you do not write

Framework detection produces entrypoints carrying more settings than gigadrive.yaml accepts, so that an adapter can describe output it already knows the shape of. The settings table is the whole set of keys you can write yourself. Anything else in a functions block passes validation and is then discarded, with no warning.