All Products
Search
Document Center

CloudOps Orchestration Service:Configure an application in a specific programming language

Last Updated:Mar 28, 2025

By default, the application management feature uses Heroku Cloud Native Buildpacks (CNBs) whose version is heroku/builder:24 to build applications. This topic describes how to use Heroku CNBs to configure applications in different programming languages, including Java, Python, Go, and Node.js.

Notes on configuring container images and containers

  • Configure environment variables when you build a container image

    Add a project.toml file to specify environment variables when you build a container image. For example, specify MAVEN_OPTS.

    Note

    For more information about project.toml, see the Introduction to project.toml section of this topic.

  • Configure environment variables to pass container runtime parameters

    Container runtime parameters are passed to the applications in environment variables. Make sure that your code can read parameters from environment variables. When you deploy a container, you can specify environment variables for the container. Application management stores the environment variables in the env file and pass the variables to the container process in the --env-file option.

Application configurations

The code repository allows you to directly deploy applications only in the following programming languages. This section describes how to configure applications in different programming languages.

Java

Requirements for applications

The following requirements apply to Java applications:

  • The root directory of the code repository must contain the pom.xml file.

  • You can use Maven or Gradle to build application code.

  • The JDK version of the application must be supported.

Configuration notes

  • OpenJDK versions

    OpenJDK major versions 8, 11, 17, 21, and 22 are supported. CNBs install the latest minor version of the specified OpenJDK major version.

    Note

    If you do not specify an OpenJDK version, CNBs install the latest long-term support (LTS) version by default, such as the latest minor version of OpenJDK 8, 11, 17, or 21.

    You can add the system.properties Java property file to the root directory of the application to specify an OpenJDK version. The following sample code shows how to specify OpenJDK 21:

    java.runtime.version=21
  • Maven options

    You can use the MAVEN_OPTS environment variable to apply Maven settings. Add the project.toml file to specify this environment variable.

    By default, CNBs support only Maven 3.9. If your application relies on other Maven versions, use the Maven Wrapper (mvnw ). CNBs use the mvnw in the root directory of the project to build the application.

    Run the following command to use the Maven Wrapper:

    mvn wrapper:wrapper # Generate the .mvn directory, the mvnw, and the mvnw.cmd file.
    git add .mvn mvnw mvnw.cmd
    git commit -m "support maven wrapper"
    git push origin # Submit the branch to the code repository.
  • Procfile

    A Procfile declares the process type and the commands that are used to start an application. For more information, see the Introduction to Procfiles section of this topic. For Spring Boot applications, a Procfile defines how the platform starts the Spring Boot applications. The following sample code shows a typical Procfile for Spring Boot applications:

    web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/demo-0.0.1-SNAPSHOT.jar

Sample projects

For more information, see buildpacks-jvm.

Python

Requirements for applications

For Python applications, the root directory of the source code must be stored in a requirements.txt or poetry.lock file.

Configuration notes

  • Python versions

    By default, CNBs install the latest Python version, which is 3.13. If you want to use other Python versions, add a .python-version file to the root directory of the application and specify the Python version that you want to use. Sample code:

    $ cat .python-version
    3.13
  • Procfile

    A Procfile is a text file in the root directory of an application. For Python applications, a Procfile declares the process type and the commands that are used to start the applications. The following sample code shows a Procfile for Python applications:

    web: gunicorn --config gunicorn.conf.py gettingstarted.wsgi
    Note

    Procfile is not a necessary file for simple applications. However, we strongly recommend that you add a Procfile to Python applications. For more information, see the Introduction to Procfiles section of this topic.

Sample projects

For more information, see buildpacks-python.

Go

Requirements for applications

The following requirements apply to Go applications:

  • The root directory of the code repository must contain the go.mod file. The module name in the go.mod file must contain at least one forward slash (/).

  • Go applications support Go 1.16 and later for compilation. Go applications also support Go modules for installing dependencies.

    Note

    CNBs support only Go dependency management, such as Go modules. Third-party dependency managers such as dep, godep, govendor, and glide are not supported.

Configuration notes

  • Go versions

    CNBs read the Go version from the go line in the go.mod file.

    For example, CNB selects the latest release from Go 1.17. Sample code:

    go 1.17
  • Dependency management

    • If the root directory of the code repository contains the vendor/modules.txt file, CNBs will attempt to use the Go modules in the vendor directory, instead of downloading them.

    • If the root directory of the code repository does not contain the vendor/modules.txt file, CNBs download the Go modules before compilation.

  • Package installation

    CNBs build all main packages that are detected by the project.

Sample projects

For more information, see buildpacks-go.

Node.js

Requirements for applications

The following requirements apply to Node.js applications:

  • During the build process, a valid package.json file must be prepared for CNBs.

  • To install dependencies, you must prepare a valid npm, yarn, or pnpm lock file.

Configuration notes

Node.js versions

Specify the engines.node field in the package.json file to specify a Node.js version. If you do not specify a Node.js version, the latest LTS version is used.

Specify the Node.js version in the package.json file. For example, specify the latest version in the 20th line. Sample code:

{"
   engines":{"
     node":"20. x"
   }
}
Note

This field supports the same syntax for controlling the semantic version as the package.json file. We strongly recommend that you specify a Node.js version to prevent unexpected changes.

Sample projects

For more information, see buildpacks-nodejs.

PHP

Application requirements

If the programming language is PHP, the application must meet the following requirements:

  • Supports PHP 8.2, PHP 8.3, and PHP 8.4.

  • The root directory of the application repository must contain the composer.json and composer.lock files.

Configuration

PHP

Specify the PHP runtime version in composer.json. The following sample code specifies PHP 8.2.0 and later versions.

{
  "require": {
    "php": "^8.2.0"
  }
}

Examples

For more information, see buildpacks-php and php-support.

Introduction to project.toml and Procfile

  • Click to view the introduction to and configurations of project.toml

    • Introduction to project.toml

      project.toml, also known as project descriptor, is a plain text file that must be stored in the project root directory. This file can be used to configure a code repository in details. For example, you can use the project.toml file to specify the buildpacks that you want to use, the files that you want to include and exclude, and how environment variables are configured when you build a code repository. For more information, see project.toml.

    • project.toml configurations

      The project.toml file mainly contains the following configurations. For more information about other configurations in the project.toml file, see Use project.toml.

      • Configure environment variables when you build an image

        In the root directory of the project, create or update the descriptor of the project.toml file. Sample environment variables:

        [_]
        schema-version = "0.2" # Required. Schema version 0.1 does not support build env.
        
        [[io.buildpacks.build.env]]
            name = "MAVEN_OPTS"
            value = "-Xms128m -Xmx512m"
        [[io.buildpacks.build.env]]
            name = "The name of Environment Variable 2"
            value = "The value of Environment Variable 2"
      • Optional. Specify the project.toml builder

        Application management specifies a default builder. You can also specify a builder. Sample code:

        [io.buildpacks]
        builder = "cnbs/sample-builder:noble"
  • Click to view the introduction to and format of Procfile

    • Introduction to Procfile

      A Procfile is a plain text file without a file name extension in the root directory of an application. This file must be stored only in the root directory. A Procfile can be used to replace the default startup process of applications in any programming language. For more information, see Procfile.

    • Procfile format

      A Procfile declares its process types on individual lines, each with the following format:

      PROCESS_TYPE: COMMAND

      Replace the following field and value:

      • Replace PROCESS_TYPE with the process type, such as web, worker, and custom.

      • Replace COMMAND with the command that is used to start the type of process, such as gunicorn -b :$PORT main:app.