Deploy previews for Spring Boot apps
Push a branch, get a live preview URL. PreviewDrop builds your fat JAR, boots the embedded server, and posts the link to the pull request, usually within a couple of minutes — no CI scripts, no serverless Java wrappers.
@Scheduled jobs, connection pools and a warm JVM are all intact, not folded into a Lambda handler.What the build needs to do
You don't write this. PreviewDrop detects Spring Bootfrom your repo and builds the container for you — a Dockerfile in your repo is not used. The reference below shows the install, build and start steps a working Spring Boot image needs. If detection gets one wrong, set the matching Install, Build or Start command in Project Settings. Your app must listen on $PORT.
Reference (not read by PreviewDrop)FROM eclipse-temurin:21-jdk AS build WORKDIR /app COPY .mvn/ .mvn COPY mvnw pom.xml ./ RUN ./mvnw dependency:go-offline -B COPY src ./src RUN ./mvnw clean package -DskipTests FROM eclipse-temurin:21-jre WORKDIR /app COPY --from=build /app/target/*.jar app.jar EXPOSE 8080 # PreviewDrop injects PORT; Spring binds to it via server.port CMD ["sh", "-c", "java ${JAVA_OPTS} -Dserver.port=${PORT:-8080} -jar app.jar"]
Environment variables
Set these in the Variables tab of your PreviewDrop project. They're encrypted at rest and injected into every preview container at start.
| Variable | Example value | Note |
|---|---|---|
| SPRING_PROFILES_ACTIVE | preview | Activates an application-preview.yml so previews can use a lighter config than prod. |
| JAVA_OPTS | -XX:MaxRAMPercentage=75 | Cap the heap so the JVM fits the preview container instead of grabbing the whole host. |
| SPRING_DATASOURCE_URL | jdbc:postgresql://host:5432/db | Point at a shared dev DB, or use an in-memory H2 profile for UI-only previews. |
Common gotchas
Bind to the injected PORT, not hard-coded 8080
PORT env var. Pass -Dserver.port=${PORT} (as in the reference Start command) or set SERVER_PORT. A hard-coded port still works as long as it matches what the proxy expects, but reading PORT is the safe default.Commit the Maven wrapper with the executable bit
./mvnw, which must be committed and executable. Windows checkouts often drop the exec bit — restore it once with git update-index --chmod=+x mvnw so the Linux build can run it. (Gradle: swap in ./gradlew bootJar.)Skip the test suite in the image build
-DskipTests. Preview builds should be fast — your full suite belongs in CI, not on the critical path to a preview URL. Keeping the build lean keeps builds fast. If detection runs your tests, set the Build command in Project Settings.Cap the JVM heap
JAVA_OPTS=-XX:MaxRAMPercentage=75 (or an explicit -Xmx256m) so the heap stays inside the container limit.Why not Vercel or Netlify?
@Scheduled jobs, hosted background workers, and a warm JVM with live connection pools. PreviewDrop runs your fat JAR directly — the same container shape as production, used as a per-PR deploy preview.Preview your Spring Boot app in 5 minutes
Connect a repo, push a branch, get a URL. No credit card, no trial clock.
Start free