Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Installation via Docker

APERTO-NOTA

Prérequis


Architecture des conteneurs

┌─────────────────────────────────────────────┐
│  docker-compose.yml                         │
│                                             │
│  ┌──────────┐   route   ┌───────────────┐  │
│  │  MS-SQL  │ ────────► │  PostgreSQL   │  │
│  │  :1433   │           │  :5432        │  │
│  └──────────┘           └───────────────┘  │
│        ▲                                    │
│        │ lit / écrit                        │
│  ┌─────┴──────┐                             │
│  │   Camel    │                             │
│  │  (Karavan) │                             │
│  │   :8080    │                             │
│  └────────────┘                             │
└─────────────────────────────────────────────┘

Structure du projet

Créer le répertoire suivant sur le poste :

camel-mssql-pg/
├── docker-compose.yml
├── camel/
│   └── routes/
│       └── mssql-to-pg.camel.yaml
└── init/
    ├── mssql-init.sql
    └── pg-init.sql

docker-compose.yml

version: '3.8'

services:

  mssql:
    image: mcr.microsoft.com/mssql/server:2022-latest
    container_name: camel-mssql
    environment:
      SA_PASSWORD: "Str0ngPass!"
      ACCEPT_EULA: "Y"
    ports:
      - "1433:1433"
    volumes:
      - ./init/mssql-init.sql:/init/mssql-init.sql

  postgres:
    image: postgres:16
    container_name: camel-postgres
    environment:
      POSTGRES_DB: targetdb
      POSTGRES_USER: camel
      POSTGRES_PASSWORD: camel
    ports:
      - "5432:5432"
    volumes:
      - ./init/pg-init.sql:/docker-entrypoint-initdb.d/pg-init.sql

  karavan:
    image: ghcr.io/apache/camel-karavan:4.8.0
    container_name: camel-karavan
    ports:
      - "8080:8080"
    volumes:
      - ./camel:/deployments/camel
    environment:
      KARAVAN_RUNTIME: camel-main
    depends_on:
      - mssql
      - postgres

Scripts d’initialisation

init/mssql-init.sql — table source

CREATE DATABASE sourcedb;
GO
USE sourcedb;
GO
CREATE TABLE produits (
    id   INT PRIMARY KEY IDENTITY,
    nom  NVARCHAR(100),
    prix DECIMAL(10,2),
    actif BIT DEFAULT 1
);
INSERT INTO produits (nom, prix) VALUES
    ('Article A', 10.50),
    ('Article B', 25.00),
    ('Article C', 7.99);

init/pg-init.sql — table cible

CREATE TABLE produits (
    id    INTEGER PRIMARY KEY,
    nom   TEXT,
    prix  NUMERIC(10,2),
    actif BOOLEAN DEFAULT TRUE
);

Lancement

# Démarrer les conteneurs
docker compose up -d

# Vérifier l'état
docker compose ps

# Accéder à l'interface Karavan
open http://localhost:8080

# Arrêter
docker compose down

Vérification MS-SQL

docker exec -it camel-mssql /opt/mssql-tools/bin/sqlcmd \
  -S localhost -U sa -P "Str0ngPass!" \
  -Q "SELECT * FROM sourcedb.dbo.produits"

Points d’attention