Aller au contenu

Docker & Déploiement

Architecture Docker

Le projet contient quatre conteneurs orchestrés via Docker Compose :

graph TD
    Internet([Internet]) --> GW[🔀 drwh_gateway\nNginx\nPort 8080/8443]
    GW --> G[🏠 drwh_group\nLaravel\nPort 3001]
    GW --> T[💻 drwh_tech\nNext.js\nPort 3003]
    GW --> I[🏗️ drwh_immo\nNext.js\nPort 3002]

    style Internet fill:#e8f4f8
    style GW fill:#2d2e2e,color:#fff
    style G fill:#e74c3c,color:#fff
    style T fill:#0066FF,color:#fff
    style I fill:#27ae60,color:#fff
Conteneur Service Port interne Port hôte par défaut
drwh_gateway Nginx Reverse Proxy 80/443 8080/8443
drwhtch_tech Next.js drwh_tech 3003
drwh_immo Next.js drwh_immo 3002
drwh_group Laravel drwh_group 3001 — (bind local unique)

Fichiers Docker

Fichier Rôle
Dockerfile.tech Construction de l'image drwh_tech
Dockerfile.immo Construction de l'image drwh_immo
Dockerfile.group Construction de l'image drwh_group
docker-compose.yml Orchestration des quatre services
infra/nginx/nginx.conf Configuration globale Nginx
infra/nginx/conf.d/ Virtual hosts per service
infra/nginx/certs/ Certificats TLS (fullchain.pem, privkey.pem)
infra/nginx/www/ Webroot ACME (Let's Encrypt)

Commandes Docker principales

bash # Depuis le dossier drwh_front cd drwh_front docker compose up --build

Accès après démarrage :
- HTTP : [http://localhost:8080](http://localhost:8080)
- HTTPS : [https://localhost:8443](https://localhost:8443)

bash # Exposer sur les ports 80/443 si disponibles DRWH_GATEWAY_HTTP_PORT=80 DRWH_GATEWAY_HTTPS_PORT=443 \ docker compose up --build

bash docker compose down

````bash # Tous les services docker compose logs -f

# Un seul service
docker compose logs -f drwh_tech
```

bash docker compose up --build drwh_tech


Variables d'environnement Docker

Les conteneurs Next.js utilisent NODE_ENV=production. Le conteneur Laravel expose APP_ENV=production, APP_DEBUG=false.

Sécurité

Pour un déploiement réel, ne jamais inclure les secrets dans docker-compose.yml. Utilisez un fichier .env sécurisé ou un gestionnaire de secrets (Vault, Docker Secrets…).

Créez un fichier .env à la racine avec les variables sensibles :

# drwh_group
DRWH_GROUP_APP_KEY=base64:...
DRWH_GROUP_DB_PASSWORD=motdepassesecret

# Ports gateway (optionnel)
DRWH_GATEWAY_HTTP_PORT=80
DRWH_GATEWAY_HTTPS_PORT=443
````

---

## Structure du `docker-compose.yml`

```yaml
services:
  drwh_gateway:
    image: nginx:alpine
    ports:
      - "${DRWH_GATEWAY_HTTP_PORT:-8080}:80"
      - "${DRWH_GATEWAY_HTTPS_PORT:-8443}:443"
    volumes:
      - ./infra/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./infra/nginx/conf.d:/etc/nginx/conf.d
      - ./infra/nginx/certs:/etc/nginx/certs
      - ./infra/nginx/www:/var/www/acme
    depends_on:
      - drwh_tech
      - drwh_immo
      - drwh_group

  drwhtch_tech:
    build:
      context: .
      dockerfile: Dockerfile.tech
    expose:
      - "3003"

  drwh_immo:
    build:
      context: .
      dockerfile: Dockerfile.immo
    expose:
      - "3002"

  drwh_group:
    build:
      context: .
      dockerfile: Dockerfile.group
    expose:
      - "3001"

HTTPS avec Let's Encrypt (production)

En production, configurez des certificats TLS valides :

flowchart LR
    A[Obtenir certificat\nLet's Encrypt] --> B[Copier dans\ninfra/nginx/certs/]
    B --> C[Configurer\nnginx.conf HTTPS]
    C --> D[docker compose up --build]

    style A fill:#27ae60,color:#fff
    style D fill:#0066FF,color:#fff
# Avec Certbot (nécessite accès root sur le serveur)
certbot certonly --webroot \
  -w ./infra/nginx/www \
  -d tech.darewatchgroup.com \
  -d immo.darewatchgroup.com \
  -d darewatchgroup.com

# Copier les certificats
cp /etc/letsencrypt/live/tech.darewatchgroup.com/fullchain.pem infra/nginx/certs/
cp /etc/letsencrypt/live/tech.darewatchgroup.com/privkey.pem infra/nginx/certs/

Déploiement VPS / Serveur dédié

Acheter et configurer un serveur

Pour déployer en production, vous avez besoin d'un serveur. Deux options courantes :

Un VPS (Virtual Private Server) est un serveur virtuel chez un hébergeur.

**Fournisseurs recommandés :**
- [OVH Cloud](https://ovh.com) — Très présent en Afrique
- [DigitalOcean](https://digitalocean.com) — Simple et bien documenté
- [Hetzner](https://hetzner.com) — Excellent rapport qualité/prix

**Configuration minimale recommandée :**
- 2 vCPUs
- 4 Go RAM
- 40 Go SSD
- Ubuntu 22.04 LTS

KVM (Kernel-based Virtual Machine) permet de virtualiser à l'échelle d'un serveur physique. Idéal si vous gérez votre propre infrastructure.

Dokploy est un outil de déploiement simplifié basé sur Docker.

**Installation sur votre VPS :**
```bash
curl -sSL https://dokploy.com/install.sh | sh
```

Dokploy fournit une interface web pour :
- Créer et gérer des services Docker
- Gérer les domaines et sous-domaines
- Inviter des membres de l'équipe
- Monitorer les logs et performances

Liens complémentaires