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:
- Go to your Hostim.dev dashboard
- Click Create Project
- Choose:
- Scratch if you're starting clean
- Template if you want the Spring Boot Demo preloaded
- Docker Compose if you have a custom setup
- For this guide, choose Scratch
- 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β
- From your dashboard, click Create Service β New Volume
- Name it something like
upload-data
- Pick a plan
- Click Create Volume
2.2. Add a PostgreSQL Databaseβ
- Click Create Service β New PostgreSQL
- Name it (e.g.,
postgres
) - Pick a plan
- Click Create PostgreSQL
2.3. Add a Redis Instanceβ
- Click Create Service β New Redis
- Name it (e.g.,
redis
) - Pick a plan
- Click Create Redis
2.4. Set Up the Spring Boot Appβ
- Click Create Service β New App
- Select Git as the deployment type
- Use the repo URL:
https://github.com/hostimdev/demo-springboot
- Set the branch to
main
- Leave Dockerfile path as
Dockerfile
- Choose a plan and number of replicas
- Under Volume Mounts, click Attach Volume
- Pick the volume you made (e.g.,
upload-data
) - Set mount path to
/app/uploads
- Pick the volume you made (e.g.,
- Check "Does this app have HTTP Service?"
- Set the HTTP Port to
8080
- Check "Is this app public?" if you want it publicly accessible
- Click Create App
2.5. Add Environment Variablesβ
- Open the app in the dashboard
- Go to the Envs tab
- 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)
Variable | Description |
---|---|
SPRING_DATASOURCE_* | Populated from the PostgreSQL service |
SPRING_REDIS_HOST | Populated from the Redis service |
Click Save Changes when done.