Functions are blocks of code that run on demand without the need to manage any infrastructure. Develop on your local machine, test your code from the command line (using
doctl), then deploy to App Platform — no servers required. Learn more about functions.
To deploy functions to production, you need to structure your source code into a project and upload that project to a GitHub repository
A project is a collection of resources, including functions, which is stored on your local computer or in a GitHub repository. Projects have a prescriptive structure that they must follow in order to deploy them to App Platform.
You can create a project manually, but we recommend the following ways to get started:
Fork one of the sample repositories of our example projects.
The project root can either be the root of a Git repository or a subdirectory in a monorepo. This top-level project root must contain the following:
A project configuration file called
A directory named
packages containing one or more packages. A package is a collection of functions. Each package must have its own directory under
Each function must be in a package directory. Functions can be a single source code file or a directory with one or more source code files.
packages directory can contain any number of packages, and each package can contain an arbitrary number of functions. This lets you organize your project in the way that makes the most sense to you.
The organization of packages determines the URL where functions are served. Functions components in App Platform are served at a URL with the structure
Here is a barebones example of the structure of a project:
example-project ├── project.yml └── packages └── example-package └── example-function.php
Here is an example structure for project with two packages,
example-package-1 has three functions, and
example-package-2 has one.
example-project ├── packages │ ├── example-package-1 │ │ ├── example-function-a.php │ │ ├── example-function-b │ │ │ ├── package.json │ │ │ └── example.js │ │ └── example-function-c │ │ └── index.php │ └── example-package-2 │ └── example-function │ ├── requirements.txt │ ├── __main__.py │ └── example.py └── project.yml