Minimum Requirement
To run a Java application at Upsun you need:- A supported Java version
- A build management tool
- A Git Repository:
A container application can’t be bigger than 8 GB of memory.
For more details, see tuning.
Monolith/Single Application
To start a Java application, you need to understand the Upsun structure. You will need to configure your application, routes, and services.Application
- A Java version, e,g.:
java:<VERSION>. - Hooks define what happens when building the application. This build process typically generates an executable file such as a uber-jar. For example,
mvn clean package. - The commands key defines the command to launch the application. For example,
java -jar file.jar. - In the start’s command needs to receive the port where the application will execute thought the
PORTenvironment. That’s best when your app follows the port bind principle. For example,java -jar jar --port=$PORT.
Be aware that after the build, it creates a read-only system. You have the mount option to create a writable folder.
Route
- It defines the application will link in the route. For example,
"myapp:http".
Application instances have a limited amount of memory at build time, which has a maximum of 8 GB.
At runtime that limit depends on your plan and configuration.
A stateless application can be scaled horizontally to multiple application instances using Varnish in a load balancer configuration.
Application instances have a limited amount of memory at build time, which has a maximum of 8 GB.
At runtime that limit depends on the resources you have defined for your application container using
upsun resources:set.
A stateless application can be scaled horizontally to multiple application instances with upsun resources:set or by using Varnish in a load balancer configuration.Microservices
You have the option to use several languages in microservices. If you’re using Java there are several options to aggregate these services into a microservices: Upsun supports multiple applications and there are two options:- One application YAML file to each application
- Aggregate all applications in a single file with an
.upsun/config.yamlfile
You can load balance to some or all applications in the project cluster.While the table above shows examples for Upsun Fixed rather than for Upsun Flex, the same rules apply with only slight changes in configuration.
Access to managed services
Upsun provides managed services such as databases, cache and search engines. However, you can use a database or any services such as a transition process, just be aware of the firewall. When applications need to access a service, it is important to include therelationships key.
By default an application may not talk to any other container without a relationship explicitly allowing access.
To connect to a service from your deployed application, you need to pass the relationships information into your application’s configuration.
The way to do so varies with the application.
The most common mechanisms are listed below.
Overwrite
If you are using a framework that follows the Twelve-Factor App methodology, particularly the third point, you can configure the application directly from environment variables. Examples of such frameworks include Spring, Eclipse MicroProfile Config, Quarkus, and Micronauts. Service credentials are available within the service environment variables, or thePLATFORM_RELATIONSHIPS environment variable.
- Service environment variables
- `PLATFORM_RELATIONSHIPS` environment variable
Assuming the relationship This sets environment variables with the names your app needs,
and the values from service environment variables.
postgresql is configured to grant access to a PostgreSQL service container, you can map the automatically generated environment variable (POSTGRESQL_HOST) to whatever your application expects to use:.environment
While the table above shows examples for Upsun Fixed rather than for Upsun Flex, the same rules apply with only slight changes in configuration.
.environment file.
Example:
You can obtain relationship information through the service environment variables themselves,
or through the PLATFORM_RELATIONSHIPS environment variable.
Say your application has a relationship named postgresql to a database service named postgresql:
- Service environment variables
- `PLATFORM_RELATIONSHIPS` environment variable
.environment
.environment file can interact to each application file.
Example: