# How to Deploy a Spring Boot App (Java & Kotlin) Without a Dockerfile

Deploy a Spring Boot app (Java or Kotlin) with Maven or Gradle in one command: PORT binding, PostgreSQL settings injected for you and JVM memory tuning.

URL: https://blog.dockhosting.dev/deploy-spring-boot-app
Published: 2026-10-22 · Updated: 2026-10-22 · Author: Doughmi ILYAS

## Summary

- DockHosting builds an executable JAR from pom.xml or build.gradle (Maven 3.9+, Gradle 8.x) on Java 17 or 21: no Dockerfile needed.
- Bind the port with server.port=${PORT:8080}; attach PostgreSQL and the spring.datasource settings are injected as environment variables.
- Cap the heap with -XX:MaxRAMPercentage so the JVM fits the container, and expect slower starts: apps get up to 5 minutes.

ort const meta = {
  title: "How to Deploy a Spring Boot App (Java & Kotlin) Without a Dockerfile",
  seoTitle: "Deploy Spring Boot Without a Dockerfile (2026)",
  description:
    "Deploy a Spring Boot app (Java or Kotlin) with Maven or Gradle in one command: PORT binding, PostgreSQL settings injected for you and JVM memory tuning.",
  date: "2026-10-22",
  category: "Guides",
  tags: ["Spring Boot", "Java", "Kotlin", "PostgreSQL", "Tutorial"],
  stack: ["spring-boot", "postgresql", "github"],
  command: "dock deploy",
  takeaways: [
    "DockHosting builds an executable JAR from pom.xml or build.gradle (Maven 3.9+, Gradle 8.x) on Java 17 or 21: no Dockerfile needed.",
    "Bind the port with server.port=${PORT:8080}; attach PostgreSQL and the spring.datasource settings are injected as environment variables.",
    "Cap the heap with -XX:MaxRAMPercentage so the JVM fits the container, and expect slower starts: apps get up to 5 minutes.",
  ],
  faq: [
    {
      q: "Do I need a Dockerfile for Spring Boot?",
      a: "No. DockHosting detects pom.xml or build.gradle, builds an executable JAR with Maven or Gradle and runs it on Eclipse Temurin (Java 17 or 21). If a Dockerfile is present, it's built from that instead.",
    },
    {
      q: "Is Kotlin supported?",
      a: "Yes. Kotlin Spring Boot projects build the same way, with Gradle or Maven.",
    },
    {
      q: "Can a Spring Boot app run on the Free plan?",
      a: "Yes. The Free plan covers a Spring Boot service with one database. Keep the heap small, and remember the app sleeps after 1 hour idle; the JVM's startup time makes the first request after a sleep slower. Hobby ($4/month) is always on.",
    },
  ],
};

Spring Boot apps are usually deployed with a hand-written Dockerfile, a JVM base image and a lot of tuning. You can skip most of that: give the platform your Maven or Gradle project and it builds the JAR for you.

## What happens on deploy

1. `pom.xml` or `build.gradle` marks the project as Java/Kotlin.
2. **Maven 3.9+** or **Gradle 8.x** builds an executable JAR.
3. The JAR runs on **Eclipse Temurin, Java 17 or 21 LTS**, with a tuned garbage collector.
4. You get `https://<project>.dockhosting.cloud` with automatic HTTPS.

Scheduled jobs (`@Scheduled`, Quartz) and background workers run alongside the web server.

## 1. Listen on the platform's port

```properties
# src/main/resources/application.properties
server.port=${PORT:8080}
server.shutdown=graceful
```

`${PORT:8080}` uses the `PORT` variable in production and 8080 locally. Graceful shutdown lets in-flight requests finish during a zero-downtime deploy.

## 2. Add PostgreSQL

Create a managed PostgreSQL database in the dashboard and attach it to the project. The **`spring.datasource` properties are injected as environment variables**, which Spring Boot maps onto its configuration automatically, so you don't hard-code a URL, user or password.

```xml
<!-- 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>
```

For schema changes, use Flyway or Liquibase. Both run at startup, before the app takes traffic.

> Set `spring.jpa.hibernate.ddl-auto=validate` in production. Letting Hibernate `update` the schema works until the day it silently doesn't.

## 3. Fit the JVM into the container

The JVM sizes its heap from the container's memory, but leaves little room for everything else. Set an explicit share:

```bash
JAVA_TOOL_OPTIONS=-XX:MaxRAMPercentage=75
```

Add it as an environment variable. Rough guide:

| Plan | Memory | Comfortable for |
|---|---|---|
| Free | 512 MB (shared with its database) | A small API |
| Hobby | 1 GB | Most single services |
| Pro | Up to 2 GB per app | Larger apps, several services |
| Team | Up to 4 GB per app | Heavy workloads |

## 4. Deploy

```bash
curl -fsSL https://cli.dockhosting.dev/install.sh | sh   # Windows: irm https://cli.dockhosting.dev/install.ps1 | iex
dock login
dock deploy
```

Follow the startup with `dock logs`. Spring Boot can take a while to start on a small container, so DockHosting gives apps **up to 5 minutes** to start listening before a start is marked as failed.

## 5. Faster startup

- **Trim starters** you don't use. Each one adds auto-configuration work at boot.
- **Lazy initialization** (`spring.main.lazy-initialization=true`) defers beans until first use, at the cost of a slower first request.
- **Expose a health endpoint** with `spring-boot-starter-actuator` (`/actuator/health`) so you can tell "starting" from "broken".

Want full control of the image instead? Add a Dockerfile and it's built as-is. See [deploying any Docker container](/deploy-docker-container).

## FAQ

### Do I need a Dockerfile for Spring Boot?

No. DockHosting detects pom.xml or build.gradle, builds an executable JAR with Maven or Gradle and runs it on Eclipse Temurin (Java 17 or 21). If a Dockerfile is present, it's built from that instead.

### Is Kotlin supported?

Yes. Kotlin Spring Boot projects build the same way, with Gradle or Maven.

### Can a Spring Boot app run on the Free plan?

Yes. The Free plan covers a Spring Boot service with one database. Keep the heap small, and remember the app sleeps after 1 hour idle; the JVM's startup time makes the first request after a sleep slower. Hobby ($4/month) is always on.
