Java and Spring Boot
Deploy a Java HTTP server from a Maven or Gradle project.
Deploy a Java HTTP app from a Maven or Gradle project. Smolcloud installs the JDK and build tools, downloads public dependencies and packages the app.
Start from the Spring template
smolcloud init spring ./my-app
This creates a small working app with a Dockerfile. You can use your own project instead. Either way, create an app first to get its ID.
The Spring Boot starter packages a JAR and runs it with a JRE. Its
application.properties sets the listener and port:
server.address=0.0.0.0
server.port=${PORT:3000}
The starter's health route is /api/health. For your own project, set the app's
health path to a route it actually serves. Run it on the same Java version you compiled with. Set the heap below the app's
memory limit, because Java needs some memory outside the heap.
Deploy source
Include pom.xml for Maven, or gradlew and its wrapper files for Gradle. Maven Central and the Gradle plugin portal are available during builds. Without a Dockerfile, Smolcloud configures Maven and Gradle to reach them for you.
Create the app to get its ID, then deploy the source folder:
smolcloud deploy APP_ID ./my-app
If the folder has a Dockerfile, Smolcloud uses it. The starter includes one; delete it if you'd rather Smolcloud work out the build itself. Automatic builds lists what a build can download and where to see the commands it chose.
Set the port and health path in the app's Configuration. deploy waits until the app is live and prints its address. Open it and try a real page, not only the health path. If you need a private package registry, build an image in your own CI and deploy that.
Limits
- The app runs as user
10001:10001, not root, and can't write to its own filesystem. - Builds can't reach private package registries or other download sites.
- Keep data in PostgreSQL, a bucket or a disk; anything else is lost on the next deploy.