Packaging Archives for Code-only Functions

Find out about archive requirements for code-only functions in OCI Functions, including runtime-specific and architecture-specific packaging rules.

Overview

A code-only function archive must use the structure expected by the selected runtime and the architecture of the OCI Functions application. Code-only functions support x86, Arm, and multi-architecture applications, and the archive layout must match the application shape.

Supported archive formats

Code-only functions support ZIP archives.

For Java code-only functions, you can also use a JAR file for a simple function. Use a ZIP archive for Java code-only functions when the function includes runtime-specific archive directories, resources, or native dependencies. Any JAR file that you provide must be an uber/fat JAR.

Runtime archive summary

The archive layout for a code-only function depends on the runtime and on whether the application uses a single architecture shape or a multi-architecture shape.

Runtime Required function code or artifact Optional resources Optional dependencies Handler requirement
Go A statically linked, self-contained Linux executable binary named func. For single-architecture applications, place func at the archive root. For multi-architecture applications, place func under both fn-arch-x86/ and fn-arch-arm/. A directory named resources/ is optional. For multi-architecture Go archives, place resources/ inside each architecture directory when needed. Package dependencies into the Go executable. No separate handler property. The executable must be named func.
Java Uber/fat JAR file for a simple function, or ZIP archive that contains exactly one root-level uber/fat JAR file. A directory named resources/ is optional at the archive root when using a ZIP archive. A directory named native/ is optional when native dependencies are required. Place native dependency files under the architecture-specific directories required by the application shape. Handler required.
Node.js function/ directory containing the handler JavaScript file. A directory named resources/ is optional at the archive root. A directory named node_modules/ is optional. For multi-architecture native dependencies, native/ is optional but, if present, must contain both fn-arch-x86/ and fn-arch-arm/. Handler required.
Python function/ directory containing the handler Python file. A directory named resources/ is optional at the archive root. A directory named python/ is optional. For multi-architecture native dependencies, native/ is optional but, if present, must contain both fn-arch-x86/ and fn-arch-arm/. Handler required in <file>.<function> format.

How application architecture affects archive layout

The application shape determines the processor architecture on which functions in the application can run. A code-only function archive must include the files required for the application's shape.

For applications with a single-architecture shape, package files for the selected architecture. For applications with a multi-architecture shape, package files for both x86 and Arm architectures when the runtime requires architecture-specific files.

Architecture-specific packaging is most important when the function includes compiled artifacts that are specific to a CPU architecture.

For example, Go functions are compiled as statically linked, self-contained Linux executable binaries. In a statically linked binary, all the external libraries, dependencies, and runtime code that an application needs to run are compiled and packed directly into a single, independent executable file. Node.js, Python, and Java functions can also include native dependencies that must match the operating system and processor architecture used by the function.

For details about selecting an application shape, see Specifying the Compute Architecture on Which to Run Functions. For runtime-specific archive layouts, see the following topics:

Native dependencies

Native dependencies are compiled libraries or binaries that a function uses at runtime. Native dependencies are built for a specific operating system and processor architecture, such as Linux on x86 or Linux on Arm.

Because native dependencies are platform-specific, package them for the architecture on which the function can run. If the application uses a single-architecture shape, include native dependencies for that architecture. If the application uses a multi-architecture shape, include native dependencies for both x86 and Arm architectures, using the runtime-specific archive layout.

Dependency installation

For Python and Node.js code-only functions, OCI Functions does not download user dependencies during function creation. Package required dependencies in the archive before creating or updating the function.

Runtime-specific topics