# MapStore2 - Smart City Digital Twin Martinique
# GeoServer local: http://geoserver:8080/geoserver
# Accès: https://mapstore.digitribe.fr
version: '3.8'

services:
  mapstore-postgres:
    image: geosolutions-mapstore/postgis:14
    container_name: mapstore-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: mapstore
      POSTGRES_PASSWORD: mapstore
      POSTGRES_DB: mapstore
    volumes:
      - mapstore2_pg_data:/var/lib/postgresql/data
    networks:
      - mapstore-network
      - smartcity-shared
      - traefik-public
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mapstore"]
      interval: 10s
      timeout: 5s
      retries: 5

  mapstore-app:
    image: geosolutionsit/mapstore2:latest
    container_name: mapstore-app
    restart: unless-stopped
    depends_on:
      mapstore-postgres:
        condition: service_healthy
    environment:
      MAPSTORE_BACKEND_PORT: 8080
      JAVA_OPTS: "-Xms512m -Xmx2g"
    volumes:
      # Configuration persistante - GeoServer local
      - ./configs/localConfig.json:/usr/local/tomcat/webapps/mapstore/configs/localConfig.json:ro
    networks:
      - mapstore-network
      - smartcity-shared
    ports:
      - "8082:8080"
    healthcheck:
      test: ["CMD-SHELL", "curl -s http://localhost:8080/ || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 5

  mapstore-proxy:
    image: nginx:alpine
    container_name: mapstore-proxy
    restart: unless-stopped
    depends_on:
      - mapstore-app
    volumes:
      # Configuration nginx persistante
      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - mapstore-network
      - smartcity-shared
      - traefik-public
    ports:
      - "80:80"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.mapstore.rule=Host(`mapstore.digitribe.fr`)"
      - "traefik.http.routers.mapstore.entrypoints=websecure"
      - "traefik.http.routers.mapstore.tls=true"
      - "traefik.http.services.mapstore.loadbalancer.server.port=80"

networks:
  mapstore-network:
    name: mapstore2_mapstore-network
    driver: bridge
  smartcity-shared:
    external: true
  traefik-public:
    external: true

volumes:
  mapstore2_pg_data:
    external: true
