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.tomlfile to specify environment variables when you build a container image. For example, specifyMAVEN_OPTS.NoteFor 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
envfile and pass the variables to the container process in the--env-fileoption.
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.xmlfile.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.
NoteIf 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.propertiesJava 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=21Maven options
You can use the
MAVEN_OPTSenvironment variable to apply Maven settings. Add theproject.tomlfile 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
mvnwin 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
Procfiledeclares 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, aProcfiledefines how the platform starts the Spring Boot applications. The following sample code shows a typicalProcfilefor Spring Boot applications:web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/demo-0.0.1-SNAPSHOT.jar
Sample projects
GitHub: github-java-springboot-demo
Gitee: gitee-java-springboot-demo
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-versionfile to the root directory of the application and specify the Python version that you want to use. Sample code:$ cat .python-version 3.13Procfile
A
Procfileis 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 aProcfilefor Python applications:web: gunicorn --config gunicorn.conf.py gettingstarted.wsgiNoteProcfile 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
GitHub: github-python-falcon-demo
Gitee: gitee-python-falcon-demo
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.modfile. Themodule namein thego.modfile 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.
NoteCNBs 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
goline in thego.modfile.For example, CNB selects the latest release from Go 1.17. Sample code:
go 1.17Dependency management
If the root directory of the code repository contains the
vendor/modules.txtfile, CNBs will attempt to use the Go modules in thevendordirectory, instead of downloading them.If the root directory of the code repository does not contain the
vendor/modules.txtfile, CNBs download the Go modules before compilation.
Package installation
CNBs build all
mainpackages that are detected by the project.
Sample projects
GitHub: github-go-web-demo
Gitee: gitee-go-web-demo
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.jsonfile must be prepared for CNBs.To install dependencies, you must prepare a valid
npm,yarn, orpnpm lockfile.
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"
}
}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
GitHub: github-nodejs-express-demo
Gitee: gitee-nodejs-express-demo
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.jsonandcomposer.lockfiles.
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
GitHub: github-php-demo
Gitee: gitee-php-demo
For more information, see buildpacks-php and php-support.