Spring Boot
Step-by-step guide to deploy a Spring Boot application on Out Plane
This guide walks you through deploying a Spring Boot application on Out Plane using Git-driven deployment with a Dockerfile.
Prerequisites
- An Out Plane account
- A GitHub account
- Java 17+ (JDK) installed on your machine
- Git installed on your machine
Create the Spring Boot App
Option 1: Using Spring Initializr (Recommended)
- Go to start.spring.io
- Configure your project:
- Project: Maven
- Language: Java
- Spring Boot: 3.2.x (latest stable)
- Group:
com.example - Artifact:
myapp - Packaging: Jar
- Java: 17 or 21
- Add dependency: Spring Web
- Click Generate to download the ZIP
- Extract to your project directory
Option 2: Using Command Line
mkdir my-spring-app
cd my-spring-appCreate pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myapp</name>
<description>Spring Boot App for Out Plane</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>Create the directory structure:
mkdir -p src/main/java/com/example/myapp
mkdir -p src/main/resourcesCreate Application Code
Create src/main/java/com/example/myapp/MyappApplication.java:
package com.example.myapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyappApplication {
public static void main(String[] args) {
SpringApplication.run(MyappApplication.class, args);
}
}Create src/main/java/com/example/myapp/HomeController.java:
package com.example.myapp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
public class HomeController {
@GetMapping("/")
public Map<String, String> home() {
return Map.of("message", "Hello from Out Plane");
}
@GetMapping("/health")
public Map<String, String> health() {
return Map.of("status", "healthy");
}
}Configure for Production
Create src/main/resources/application.properties:
# Server configuration
server.port=${PORT:8080}
# Actuator endpoints for health checks
management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=alwaysThis configuration reads the port from the PORT environment variable, defaulting to 8080.
Create the Dockerfile
Create a file called Dockerfile in your project root:
FROM eclipse-temurin:17-jdk-alpine AS builder
WORKDIR /app
COPY pom.xml .
COPY .mvn .mvn
COPY mvnw .
RUN chmod +x mvnw
RUN ./mvnw dependency:go-offline -B
COPY src ./src
RUN ./mvnw package -DskipTests -B
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY --from=builder /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]If you don't have the Maven wrapper (mvnw), generate it with: mvn wrapper:wrapper
Create a .dockerignore file:
target
.git
.gitignore
*.md
.idea
*.iml
.DS_StoreTest Locally
Build and run the application:
./mvnw spring-boot:runOr build the JAR and run it:
./mvnw package -DskipTests
java -jar target/myapp-0.0.1-SNAPSHOT.jarOpen http://localhost:8080 in your browser. You should see the JSON response.
Test the health endpoint at http://localhost:8080/health.
Push to GitHub
Initialize a Git repository and push to GitHub:
git init
git add .
git commit -m "Initial commit"
git remote add origin [email protected]:YOUR_USERNAME/my-spring-app.git
git branch -M main
git push -u origin mainReplace YOUR_USERNAME with your GitHub username.
Deploy on Out Plane
Step 1: Install GitHub App
- Go to console.outplane.com
- Navigate to Applications from the sidebar
- Click Deploy Application
- If prompted, click Install GitHub App
- Select which repositories Out Plane can access
- Click Install and you'll be redirected back
Step 2: Select Repository
- Find your repository in the list
- Click to select it
- Choose the branch to deploy (default:
main) - Set Root Directory to
/
Step 3: Configure Build
| Setting | Value |
|---|---|
| Build Method | Select Dockerfile |
| Application Name | Enter a unique name (e.g., my-spring-app) |
| Port | 8080 |
Step 4: Select Resources
| Instance | vCPU | RAM | Recommended For |
|---|---|---|---|
| op-46 | 1 | 1 GB | Small apps |
| op-82 | 2 | 2 GB | Production (recommended) |
| op-94 | 4 | 4 GB | High traffic |
Spring Boot applications typically require at least 512MB RAM. For production workloads, op-82 or higher is recommended.
Step 5: Configure Scaling
- Min Scale: Set to
1for always-on, or0for scale-to-zero - Max Scale: Set based on expected traffic
Step 6: Environment Variables (Optional)
Click Add Variable to add environment variables:
| Key | Value |
|---|---|
SPRING_PROFILES_ACTIVE | production |
DATABASE_URL | Your database connection string |
Step 7: Deploy
- Review your configuration
- Click Create Application
- Wait for the build to complete (typically 3-5 minutes)
Step 8: Access Your App
Once the deployment status shows Ready:
- Go to the application Overview tab
- Find your domain:
my-spring-app.outplane.app - Click to open your live application
- Check health at
my-spring-app.outplane.app/actuator/health
Adding a Database
Step 1: Create a Database
- Go to Databases in the sidebar
- Click Create Database
- Choose a name, PostgreSQL version, and region
- Click Create Database
Step 2: Get Connection String
- Click on your database
- In the Overview tab, find the connection details
- Note the host, port, database name, username, and password
Step 3: Add PostgreSQL Dependency
Add to your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>Step 4: Configure Database Connection
Update src/main/resources/application.properties:
# Server configuration
server.port=${PORT:8080}
# Database configuration
spring.datasource.url=${DATABASE_URL:jdbc:postgresql://localhost:5432/mydb}
spring.datasource.username=${DATABASE_USERNAME:postgres}
spring.datasource.password=${DATABASE_PASSWORD:}
# JPA configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialectStep 5: Add Environment Variables
- Go to your application in Out Plane
- Click Settings → Environment
- Add the database variables:
| Key | Value |
|---|---|
DATABASE_URL | jdbc:postgresql://host:5432/dbname |
DATABASE_USERNAME | Your database username |
DATABASE_PASSWORD | Your database password |
- Click Save and redeploy
Production Optimizations
JVM Memory Settings
For production, optimize JVM memory in your Dockerfile:
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-jar", "app.jar"]Using Gradle Instead
If you prefer Gradle, create build.gradle:
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
java {
sourceCompatibility = '17'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
}Update your Dockerfile for Gradle:
FROM eclipse-temurin:17-jdk-alpine AS builder
WORKDIR /app
COPY gradlew .
COPY gradle gradle
COPY build.gradle .
COPY settings.gradle .
RUN chmod +x gradlew
RUN ./gradlew dependencies --no-daemon
COPY src src
RUN ./gradlew bootJar --no-daemon
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]Automatic Deployments
Push to your branch to trigger automatic deployments:
git add .
git commit -m "Add new feature"
git push origin mainNext Steps
Buildpack alternative: Instead of Dockerfile, select Buildpack. Spring Boot apps are auto-detected and built using the Paketo buildpack.