Customize Quarkus for Platform.sh
Now that your code contains all of the configuration to deploy on Platform.sh, it’s time to make your Quarkus site itself ready to run on a Platform.sh environment. There are a number of additional steps that are either required or recommended, depending on how well you want to optimize your site.
Platform.sh provides all information about the running environment, including how to connect to services, through environment variables. These may be accessed directly, but it’s often easier to use the Platform.sh Config Reader library. It’s a set of utilities to wrap the environment variables and make them a bit more ergonomic to work with.
Below is an example of how to install the Config Reader for Java using Maven:
<dependency> <groupId>sh.platform</groupId> <artifactId>config</artifactId> <version>2.2.2</version> </dependency>
compile group: 'sh.platform', name: 'config', version: '2.2.2'
.platform.app.yaml file on the previous page has been pulled directly from the Quarkus template. It is sufficient to deploy Quarkus on it’s own, but since Eclipse MicroProfile makes it possible to overwrite configurations without impacting the application itself, you might elect to rely more heavily on environment variables in it’s place.
Consider this simplified
name: app type: "java:11" disk: 1024 hooks: build: ./mvnw package -DskipTests -Dquarkus.package.uber-jar=true web: commands: start: java -jar $JAVA_OPTS $CREDENTIAL -Dquarkus.http.port=$PORT target/file.jar
On Platform.sh, we can set the environment variable
JAVA_OPTS by committing a
.environment file to the repository’s root. Platform.sh runs
source .environment in the application root when a project starts, and when logging into the environment over SSH.
That gives you a place to do extra environment variable setup before the application runs, including modifying the system
$PATH and other shell level customizations.
It allows us to define
JAVA_OPTS when running on Platform.sh, but otherwise not be used during local development testing.
# .environment export JAVA_OPTS="-Xmx$(jq .info.limits.memory /run/config.json)m -XX:+ExitOnOutOfMemoryError"
To check the Garbage collector settings, please, check the Java Performance tuning section.