Annexe: Options d'hébergement
Ce guide présente les différentes options pour héberger votre API Spring Boot, du développement local jusqu'à la production.
1. Développement local (Gratuit)
Pour le développement et les tests, vous n'avez besoin de rien d'autre que votre ordinateur.
| Composant | Solution locale |
|---|---|
| Application | ./mvnw spring-boot:run |
| Base de données | H2 (en mémoire) |
| Emails | MailHog (Docker) |
# Démarrer MailHog pour tester les emails
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog
# Démarrer l'application
./mvnw spring-boot:run
# Accéder à l'API: http://localhost:8080
# Voir les emails: http://localhost:8025
Coût: 0$
2. Pourquoi pas Vercel ?
Vercel est excellent pour les frontends (React, Next.js, Vue) mais ne supporte pas Spring Boot :
| Critère | Vercel | Spring Boot |
|---|---|---|
| Langages | Node.js, Python, Go | Java |
| Type | Serverless / Frontend | Backend traditionnel |
| JVM | Non supporté | Requis |
Vercel = Frontend | Railway/Render/Heroku = Backend Java
Si vous avez un frontend React + backend Spring Boot :
- Frontend → Vercel (gratuit)
- Backend → Railway ou Render (gratuit)
3. Options Cloud gratuites (limités)
Railway
| Caractéristique | Détail |
|---|---|
| URL | https://railway.app |
| Gratuit | 500 heures/mois + 5$ crédit |
| PostgreSQL | Inclus gratuitement |
| Déploiement | Connexion GitHub automatique |
| Difficulté | Facile |
# Déployer sur Railway
# 1. Connecter votre repo GitHub
# 2. Railway détecte Spring Boot automatiquement
# 3. Ajouter les variables d'environnement
# 4. Déploiement automatique!
Render
| Caractéristique | Détail |
|---|---|
| URL | https://render.com |
| Gratuit | 750 heures/mois (spin down après 15 min) |
| PostgreSQL | Gratuit 90 jours |
| Déploiement | GitHub ou Docker |
| Difficulté | Facile |
Fly.io
| Caractéristique | Détail |
|---|---|
| URL | https://fly.io |
| Gratuit | 3 VMs partagées |
| PostgreSQL | 3GB gratuit |
| Déploiement | CLI ou Dockerfile |
| Difficulté | Moyen |
4. Hébergement VPS pas cher
Hostinger VPS
| Plan | RAM | CPU | Stockage | Prix |
|---|---|---|---|---|
| KVM 1 | 4 GB | 1 vCPU | 50 GB | 4.99$/mois |
| KVM 2 | 8 GB | 2 vCPU | 100 GB | 8.99$/mois |
| KVM 4 | 16 GB | 4 vCPU | 200 GB | 14.99$/mois |
Avantages Hostinger:
- Prix très compétitifs
- Panel de gestion simple
- Support 24/7
- Snapshots gratuits
Installation sur Hostinger VPS:
# 1. Connecter en SSH
ssh root@votre-ip
# 2. Installer Docker
curl -fsSL https://get.docker.com | sh
# 3. Installer Docker Compose
apt install docker-compose -y
# 4. Cloner votre projet
git clone https://github.com/votre-user/votre-projet.git
cd votre-projet
# 5. Démarrer avec Docker
docker-compose up -d
DigitalOcean
| Plan | RAM | CPU | Stockage | Prix |
|---|---|---|---|---|
| Basic | 1 GB | 1 vCPU | 25 GB | 6$/mois |
| Basic | 2 GB | 1 vCPU | 50 GB | 12$/mois |
| Basic | 4 GB | 2 vCPU | 80 GB | 24$/mois |
Bonus: 200$ de crédit gratuit pour les étudiants via GitHub Education.
Hetzner
| Plan | RAM | CPU | Stockage | Prix |
|---|---|---|---|---|
| CX11 | 2 GB | 1 vCPU | 20 GB | 3.29€/mois |
| CX21 | 4 GB | 2 vCPU | 40 GB | 5.83€/mois |
| CX31 | 8 GB | 2 vCPU | 80 GB | 10.59€/mois |
Le moins cher d'Europe!
OVH
| Plan | RAM | CPU | Stockage | Prix |
|---|---|---|---|---|
| Starter | 2 GB | 1 vCPU | 20 GB | 3.50€/mois |
| Essential | 4 GB | 2 vCPU | 40 GB | 6.50€/mois |
5. Platform as a Service (PaaS)
Heroku
| Plan | Détail | Prix |
|---|---|---|
| Eco | 1000 heures/mois partagées | 5$/mois |
| Basic | Toujours actif | 7$/mois |
| Standard | Performance | 25$/mois |
PostgreSQL Heroku:
- Mini: Gratuit (10K lignes)
- Basic: 9$/mois
- Standard: 50$/mois
Google Cloud Run
| Caractéristique | Détail |
|---|---|
| Gratuit | 2 millions requêtes/mois |
| Prix | 0.00002$/requête après |
| Scaling | Automatique (0 à N) |
Idéal si vous avez peu de trafic!
6. Comparatif des prix
Options les moins chères
| Rang | Service | Prix/mois | Type |
|---|---|---|---|
| 1 | Hetzner CX11 | 3.29€ | VPS |
| 2 | OVH Starter | 3.50€ | VPS |
| 3 | Hostinger KVM 1 | 4.99$ | VPS |
| 4 | Railway | 5$ crédit | Cloud |
| 5 | Heroku Eco | 5$ | PaaS |
| 6 | DigitalOcean | 6$ | VPS |
Gratuit pour les étudiants
| Service | Offre étudiante |
|---|---|
| GitHub Education | DigitalOcean 200$, Heroku, etc. |
| Azure for Students | 100$ crédit |
| Google Cloud | 300$ crédit |
| AWS Educate | Crédit variable |
7. Recommandations par cas d'usage
Pour un projet étudiant
Recommandé: Railway ou Render (gratuit)
Alternative: Heroku Eco (5$/mois)
Pour un portfolio personnel
Recommandé: Hostinger VPS (4.99$/mois)
Alternative: Hetzner (3.29€/mois)
Pour une startup / production
Recommandé: DigitalOcean ou Hetzner
Alternative: Google Cloud Run (pay-per-use)
8. Configuration pour la production
Variables d'environnement requises
# Base de données
DB_HOST=localhost
DB_PORT=5432
DB_NAME=contactdb
DB_USER=postgres
DB_PASSWORD=motdepasse_securise
# Email (exemple avec Gmail)
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USER=votre@gmail.com
MAIL_PASSWORD=app_password
# JWT
JWT_SECRET=votre_cle_secrete_base64_256bits
JWT_EXPIRATION=86400000
# Admin
ADMIN_EMAIL=admin@votredomaine.com
Avec Nginx (reverse proxy)
server {
listen 80;
server_name api.votredomaine.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Avec HTTPS (Let's Encrypt)
# Installer Certbot
apt install certbot python3-certbot-nginx -y
# Obtenir certificat SSL gratuit
certbot --nginx -d api.votredomaine.com
9. Checklist déploiement
- Choisir un hébergeur
- Créer le serveur/instance
- Installer Docker
- Configurer les variables d'environnement
- Déployer avec
docker-compose up -d - Configurer un nom de domaine (optionnel)
- Activer HTTPS (optionnel mais recommandé)
- Tester les endpoints
10. Domaines pas chers
| Registrar | Prix .com | Prix .dev |
|---|---|---|
| Namecheap | ~9$/an | ~15$/an |
| Porkbun | ~9$/an | ~13$/an |
| Cloudflare | ~9$/an (coût) | ~11$/an |
| OVH | ~10€/an | ~15€/an |
Astuce: Cloudflare vend les domaines au prix coûtant (pas de marge).
Résumé
| Budget | Recommandation |
|---|---|
| 0$ | Railway / Render / Local |
| ~5$/mois | Heroku Eco ou Hostinger |
| ~10$/mois | DigitalOcean ou Hetzner |
| Étudiant | GitHub Education (200$ gratuit) |