Skip to main content

Deploy Spring Boot on DCDeploy

This guide helps you deploy a Spring Boot application on DCDeploy—from setup, build config, to monitoring.

Quick Start: Hello World

You can deploy a minimal Spring Boot app to test the flow.
  1. Create a new Spring Boot project (using Spring Initializr or CLI):
  2. Modify src/main/java/com/example/demo/DemoApplication.java:
  1. Add a Dockerfile (if using Docker for deployment) or prepare the build to be invoked by DCDeploy.
  2. Push the code to a Git repository.
  3. Deploy on DCDeploy using the steps in this guide.

Overview

Spring Boot is a Java framework for building production-grade standalone applications with embedded servers (Tomcat, Jetty, etc.). On DCDeploy, you can deploy Spring Boot apps via:
  • Build from Code (auto-detecting Java/Maven/Gradle projects)
  • Dockerfile, for full control (custom JVM options, multi-stage builds)

Prerequisites

  • Java 17+ or appropriate version for your app.
  • Build tool: Maven or Gradle in your repo.
  • pom.xml or build.gradle describing dependencies.
  • A Git repository.
  • If using Docker, include a Dockerfile.
  • Application should read port from environment (e.g. $ or fallback) and listen on 0.0.0.0.

Step-by-Step Guide

  1. Prepare Your Spring Boot App
  • Ensure your main class (with @SpringBootApplication) is correctly set.
  • Update application.properties or application.yml to use environment variables:
Do not hardcode secrets in code. Use environment variables or Secrets management.
  1. Add Dockerfile (optional but often preferred) Example Dockerfile with multi-stage build:
  1. Push Code to Git
  • Initialize Git if needed, commit all files.
  • If using .gitignore, exclude target/, .mvn/, .settings, etc.
  1. Deploy on DCDeploy
  • In DCDeploy dashboard → go to your environment → Deploy tab.
  • Add a new service → choose Build from Code or Docker Registry.
  • Provide repo + branch.
  • Set port to 8080 (or configured port), ensure the app listens on 0.0.0.0.
  • Choose protocol (HTTP/HTTPS), region(s).
  • Provide environment variables:
  • DATABASE_URL, DB_USER, DB_PASS etc.
  • SPRING_PROFILES_ACTIVE if you use profiles.
  • Choose machine type (CPU/RAM) based on expected load.
  • Set scaling parameters (minScale / maxScale).
  • Deploy and monitor build & deployment logs.

Example Service Configuration

Best Practices

  • Use multi-stage Docker builds to reduce image size.
  • Set server.port dynamically via $ environment variable.
  • Use internal networking for databases and other services inside DCDeploy.
  • Use health checks (for example /actuator/health) to allow DCDeploy to monitor readiness.
  • Configure logging and monitoring.
  • Use secrets instead of hard-coded credentials.

Troubleshooting