name: cohaise-crm x-timezone: &timezone TZ: Europe/Paris x-restart: &restart restart: unless-stopped # Publication du front : build Vite puis export atomique dans le volume nginx. x-app: &app container_name: cohaise-crm-builder restart: "no" build: context: . dockerfile: docker/Dockerfile.app target: export command: sh /publish.sh volumes: - ./docker/publish.sh:/publish.sh:ro # Les services de migration tournent l'executable cohaise-migrate depuis # backend/shared. Ils ne lisent aucun fichier .env : Docker resout les # variables ci-dessous au lancement, elles ne passent donc jamais par un # terminal ni par le depot. x-migrate-build: &migrate-build context: . dockerfile: docker/Dockerfile.api args: APP_DIR: backend/shared services: app-build: <<: *app build: context: . dockerfile: docker/Dockerfile.app target: export args: APP_DIR: frontend/crm volumes: - app_data:/output - ./docker/publish.sh:/publish.sh:ro nginx: container_name: cohaise-crm-nginx build: context: . dockerfile: docker/Dockerfile args: NGINX_CONF: crm.conf ports: # Tunnel Cloudflare en amont : n'ecouter que sur la boucle locale. - "127.0.0.1:${CRM_HTTP_PORT:-8082}:80" # Le tunnel Cloudflare joint nginx par son nom sur le reseau partage. networks: - default - shared-network environment: <<: *timezone volumes: - app_data:/usr/share/nginx/html healthcheck: test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/healthz || exit 1"] interval: 10s timeout: 3s retries: 3 <<: *restart db: container_name: cohaise-crm-db image: mariadb:11.4 environment: <<: *timezone MARIADB_ROOT_PASSWORD: ${CRM_DB_ROOT_PASSWORD} MARIADB_DATABASE: ${CRM_DATABASE} MARIADB_USER: ${CRM_DB_USER} MARIADB_PASSWORD: ${CRM_DB_PASSWORD} ports: - "127.0.0.1:${CRM_DB_PORT:-3307}:3306" healthcheck: test: [ "CMD-SHELL", "healthcheck.sh --connect --innodb_initialized", ] interval: 10s timeout: 5s retries: 5 volumes: - db_data:/var/lib/mysql <<: *restart migrate: build: *migrate-build image: cohaise-crm-migrate restart: "no" depends_on: db: condition: service_healthy environment: <<: *timezone NODE_ENV: production LOG_LEVEL: ${LOG_LEVEL:-info} DB_HOST: db DB_PORT: "3306" DB_USER: ${CRM_DB_USER} DB_PASSWORD: ${CRM_DB_PASSWORD} DB_NAME: ${CRM_DATABASE} command: ["node", "dist/cli.js", "--dir", "/migrations"] volumes: - ./backend/crm/migrations:/migrations:ro # Pas de MEDIA_DIR : le CRM ne stocke aucun fichier, seule la base suffit. # migrate est un prerequis car runMigrations rejoue le meme dossier au # demarrage du service : les deux chemins doivent voir les memes versions. api: container_name: cohaise-crm-api build: context: . dockerfile: docker/Dockerfile.api args: APP_DIR: backend/crm image: cohaise-crm-api restart: unless-stopped depends_on: db: condition: service_healthy migrate: condition: service_completed_successfully environment: <<: *timezone NODE_ENV: production LOG_LEVEL: ${LOG_LEVEL:-info} PORT: "8080" DB_HOST: db DB_PORT: "3306" DB_USER: ${CRM_DB_USER} DB_PASSWORD: ${CRM_DB_PASSWORD} DB_NAME: ${CRM_DATABASE} DB_CONNECTION_LIMIT: ${CRM_DB_CONNECTION_LIMIT:-8} SESSION_SECRET: ${SESSION_SECRET} SESSION_TTL_HOURS: ${SESSION_TTL_HOURS:-336} TRUST_PROXY: ${TRUST_PROXY:-true} CORS_ORIGIN: ${CRM_CORS_ORIGIN:-} ports: - "127.0.0.1:${CRM_API_PORT:-3202}:8080" healthcheck: test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8080/healthz"] interval: 15s timeout: 5s retries: 5 start_period: 20s <<: *restart volumes: app_data: db_data: networks: # Reseau partage avec le tunnel Cloudflare et les autres applications de # l'hote. Externe : cree par le compose du tunnel, pas par ce projet. shared-network: external: true