Skip to main content

Deploy Spring Boot on Hostim.dev

This guide shows how to deploy a Spring Boot app on Hostim.dev from a Git repository.

Quick start: Use the "Spring Boot Demo" template to skip the setup.

πŸ‘‰ Open the Console Click "+ New Project", pick Spring Boot Demo, and you're good to go.

Want to customize or start fresh? This guide walks you through the manual setup.


0. Create a Project​

Start by setting up a new project:

  1. Go to your Hostim.dev dashboard
  2. Click Create Project
  3. Choose:
    • Scratch if you're starting clean
    • Template if you want the Spring Boot Demo preloaded
    • Docker Compose if you have a custom setup
  4. For this guide, choose Scratch
  5. Name your project (e.g. springboot-demo) and click Create Project

1. Use the Example Spring Boot App​

We'll use the public demo app as our example:

πŸ”— https://github.com/hostimdev/demo-springboot

You only need to clone it if you want to run it locally or see the code. In that case, follow the steps in the project's README:

🐳 It already has a working Dockerfile and is ready to go.


2. Deploy on Hostim.dev​

⚠️ Order matters: Create services in this order – Volume β†’ PostgreSQL β†’ Redis β†’ App. That way, everything is available when your app starts.


2.1. Create a Volume for File Uploads​

  1. From your dashboard, click Create Service β†’ New Volume
  2. Name it something like upload-data
  3. Pick a plan
  4. Click Create Volume

2.2. Add a PostgreSQL Database​

  1. Click Create Service β†’ New PostgreSQL
  2. Name it (e.g., postgres)
  3. Pick a plan
  4. Click Create PostgreSQL

2.3. Add a Redis Instance​

  1. Click Create Service β†’ New Redis
  2. Name it (e.g., redis)
  3. Pick a plan
  4. Click Create Redis

2.4. Set Up the Spring Boot App​

  1. Click Create Service β†’ New App
  2. Select Git as the deployment type
  3. Use the repo URL: https://github.com/hostimdev/demo-springboot
  4. Set the branch to main
  5. Leave Dockerfile path as Dockerfile
  6. Choose a plan and number of replicas
  7. Under Volume Mounts, click Attach Volume
    • Pick the volume you made (e.g., upload-data)
    • Set mount path to /app/uploads
  8. Check "Does this app have HTTP Service?"
  9. Set the HTTP Port to 8080
  10. Check "Is this app public?" if you want it publicly accessible
  11. Click Create App

2.5. Add Environment Variables​

  1. Open the app in the dashboard
  2. Go to the Envs tab
  3. Add these environment variables:
SPRING_DATASOURCE_URL=jdbc:postgresql://$(POSTGRES_POSTGRES_HOST):$(POSTGRES_POSTGRES_PORT)/$(POSTGRES_POSTGRES_DATABASE)
SPRING_DATASOURCE_USERNAME=$(POSTGRES_POSTGRES_USER)
SPRING_DATASOURCE_PASSWORD=$(POSTGRES_POSTGRES_PASSWORD)
SPRING_REDIS_HOST=$(REDIS_REDIS_HOST)
VariableDescription
SPRING_DATASOURCE_*Populated from the PostgreSQL service
SPRING_REDIS_HOSTPopulated from the Redis service

Click Save Changes when done.


βœ… Next Steps​